logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
6.0.0-alpha.3
  • Components Overview
  • Changelog
    v6.0.0-alpha.3
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
      DEPRECATED
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
When To Use
Difference with Flex component
Examples
Basic Usage
Vertical Space
Space Size
Align
Wrap
separator
Compact Mode for form component
Button Compact Mode
Vertical Compact Mode
Custom semantic dom styling
API
Size
Space.Compact
Semantic DOM
Design Token

Space

Set components spacing.
Importimport { Space } from "antd";
GitHub
components/spaceIssueOpen issues
Docs
Edit this page
contributors
MasonrySplitter

Resources

Ant Design X
Ant Design Charts
Ant Design Pro
Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Web3
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

  • Avoid components clinging together and set a unified space.
  • Use Space.Compact when child form components are compactly connected and the border is collapsed (After version antd@4.24.0 Supported).

Difference with Flex component

  • Space is used to set the spacing between inline elements. It will add a wrapper element for each child element for inline alignment. Suitable for equidistant arrangement of multiple child elements in rows and columns.
  • Flex is used to set the layout of block-level elements. It does not add a wrapper element. Suitable for layout of child elements in vertical or horizontal direction, and provides more flexibility and control.

Examples

API

Common props ref:Common props

PropertyDescriptionTypeDefaultVersion
alignAlign itemsstart | end |center |baseline-4.2.0
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props: SpaceProps })=> Record<SemanticDOM, string>-
directionThe space directionvertical | horizontalhorizontal4.1.0
orientationThe space directionvertical | horizontalhorizontal
sizeThe space sizeSize | Size[]small4.1.0 | Array: 4.9.0
splitSet split, please use separator insteadReactNode-4.7.0
separatorSet separatorReactNode--
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props: SpaceProps })=> Record<SemanticDOM, CSSProperties>-
verticalOrientation, Simultaneously configure with orientation and prioritize orientationbooleanfalse-
wrapAuto wrap line, when horizontal effectivebooleanfalse4.9.0

Size

'small' | 'middle' | 'large' | number

Space.Compact

Use Space.Compact when child form components are compactly connected and the border is collapsed. The supported components are:

  • Button
  • AutoComplete
  • Cascader
  • DatePicker
  • Input/Input.Search
  • InputNumber
  • Select
  • TimePicker
  • TreeSelect
PropertyDescriptionTypeDefaultVersion
blockOption to fit width to its parent's widthbooleanfalse4.24.0
directionSet direction of layoutvertical | horizontalhorizontal4.24.0
orientationSet direction of layoutvertical | horizontalhorizontal
verticalOrientation, Simultaneously configure with orientation and prioritize orientationbooleanfalse-
sizeSet child component sizelarge | middle | smallmiddle4.24.0

Semantic DOM

Design Token

Global TokenHow to use?
Basic Usage

Crowded components horizontal spacing.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Vertical Space

Crowded components vertical spacing.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Space Size

Use size to set the spacing, Three sizes are preset: small, middle, large. You can also customize the spacing. If size is not set, the spacing is small.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Align

Config item align.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Wrap

Auto wrap line.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
separator

Crowded components separator.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Compact Mode for form component

Compact Mode for form component.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Button Compact Mode

Button component compact example.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Vertical Compact Mode

Vertical Mode for Space.Compact, support Button only.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom semantic dom styling

You can customize the semantic dom style of Space by passing objects/functions through classNames and styles.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Space
Card

Card content

Card content

Card

Card content

Card content

Card

Card content

Card content



center
Block
start
Block
end
Block
baseline
Block
Link
Link
Link
Zhejiang
Zhejianggggg
 
Option1
Option1-1
Option2-2
Between
Sign Up
Email
Select Address
leaf1
$
$
$


•
•
  • root
    Root element with flex layout, gap settings, alignment, wrap and other spacing container basic styles
  • item
    Wrapped item element with spacing item layout and styles, providing wrapper for each child element for inline alignment
  • separator
    Separator element with divider styling