logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.26.0
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • 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
    • 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
      5.13.0
When To Use
Difference with Flex component
Examples
Basic Usage
Vertical Space
Space Size
Align
Wrap
Split
Compact Mode for form component
Button Compact Mode
Vertical Compact Mode
API
Size
Space.Compact
Semantic DOM
Design Token

Space

Set components spacing.
Importimport { Space } from "antd";
Sourcecomponents/space
Docs
Edit this pageChangelog
contributors
  • LayoutSplitter

    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
    Twitter
    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
    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
    classNamesSemantic classNameRecord<SemanticDOM, string>-
    directionThe space directionvertical | horizontalhorizontal4.1.0
    sizeThe space sizeSize | Size[]small4.1.0 | Array: 4.9.0
    splitSet splitReactNode-4.7.0
    stylesSemantic styleRecord<SemanticDOM, CSSProperties>-
    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
    sizeSet child component sizelarge | middle | smallmiddle4.24.0

    Semantic DOM

    Design Token

    Global TokenHow to use?
    Basic Usage

    Crowded components horizontal spacing.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Vertical Space

    Crowded components vertical spacing.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    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
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Align

    Config item align.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Wrap

    Auto wrap line.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Split

    Crowded components split.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Compact Mode for form component

    Compact Mode for form component.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Button Compact Mode

    Button component compact example.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Vertical Compact Mode

    Vertical Mode for Space.Compact, support Button only.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    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
    $
    $
    $


    • item
      5.6.0
      Wrapped item element