Ant Design Svelte

Grid

24 column grid: Row, Col, spacing, adaptability and createBreakpoint.

When to use

Grid divides the line into 24 parts and sets the proportions of the page areas. Use Row and Col for forms, cards, and columns with a common grid. For free alignment of immediate children, Flex is suitable.

Place Col inside the Row, and place the contents or nested Row already in the column. This is a flexbox layout with regular div elements, not table semantics.

Rows, columns and spacing

span determines the column share: three Cols with span=8 occupy the entire line. If the amount is greater than 24, the next column is transferred entirely; wrap=false for Row disables wrapping. span=0 hides the column.

Problem Setting Example
Split available width Row, Col.span 24 column grid
Expand columns and rows gutter={[horizontal, vertical]} Horizontal and vertical gutter
Leave space in front of the column offset Column offset
Adjust alignment justify, align Vertical alignment
Combine shares and flexible width Col.flex Flexible column width

gutter accepts a number, CSS string or map of numeric values ​​by breakpoint; the pair specifies intervals along two axes. Horizontal gutter uses negative Row padding and half column padding. Give the container room for them so that the grid doesn't create horizontal overflow on the page.

offset leaves beats in front of the column, push/pull shifts it, order changes the visual sequence. They do not change the reading order and Tab: for interactive elements, maintain a logical DOM order.

Responsiveness and theme

Xs/sm/md/lg/xl/xxl/xxxl accept a span or an object with span, offset, order, push, pull and flex. Narrower range values ​​last until the next override. Adaptive number of columns and adaptive flex show these shapes.

Thresholds refer to the width of the viewport, not the card. Standard borders sm/md/lg/xl/xxl/xxxl - 576/768/992/1200/1600/1920 px. Row also accepts responsive align, justify and gutter.

The general theme.token.screen* controls the Row observation, and screen*min controls the Col media queries. When setting thresholds, agree on the minimum and maximum limits. Example of your thresholds uses a separate provider area; responsive CSS Col works without JavaScript.

There are no proprietary named Grid component design tokens. theme.components.Grid can refine common tokens and algorithms, as in example theme. Component overrides screen* by themselves do not change media queries Col. class/style and bind:nativeElement are available Row and Col; There are no separate classNames/styles or ConfigProvider.grid.

Row.prefixCls specifies the full local CSS row prefix, including wrap, align, justify, and RTL states. The empty string and undefined use ConfigProvider.prefixCls with the -row suffix. String prefixes show independent areas, responsive gutter and form field saving. Negative row margins and column padding continue to work together.

Row and Col resolve local prefixCls independently; empty string/undefined inherit the common prefix. Col renames the responsive classes and keeps the service namespace of the common provider without dots. FormItem takes into account the prefix and responsive geometry of the columns. theme.cssVar.prefix sets theme variables independent of row classes.

Screen monitoring

createBreakpoint - Svelte model with reactive screens and connected. Create it when you initialize the component; in onMount, connect breakpoint.connect(window) and return the resulting cleanup. Before connection, screens is empty, connected=false, so SSR does not require window.

The model uses the default breakpoints unless given explicit queries. The second argument to connect sets custom media queries. The breakpoint example uses Grid.useBreakpoint(). Call this hook during component initialization. It returns a reactive map based on the nearest theme and manages the browser subscriptions.

For a regular adaptive grid, props Row/Col are enough. Observation is needed when an application changes content or behavior to fit the screen size; read model fields reactively rather than keeping a one-time copy of screens.

Examples

col-24
col-12
col-12
col-8
col-8
col-8
col-6
col-6
col-6
col-6

24 column grid

Row contains Col. span specifies the fraction of 24; a sum greater than 24 moves the following columns to a new line.

col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6

Horizontal and vertical gutter

A pair of values ​​specifies the distance between columns and rows. A CSS string is valid for constant spacing, an object is valid for responsive numbers.

col-8
col-8
col-6 col-offset-6
col-6 col-offset-6
col-12 col-offset-6

Column offset

offset adds empty beats before the column. The content remains in the same DOM order.

col-18 col-push-6
col-6 col-pull-18

Push and pull movement

push/pull visually shifts the columns. They do not change the reading order and Tab order.

col-4
col-4
col-4
col-4

Horizontal distribution

justify sets the position of the columns and free space within the Row.

55
85
115

Vertical alignment

align aligns columns of different heights to the top, middle or bottom.

Item 1
Item 2
Item 3

Column order

order changes the visual order while preserving the DOM. Use this with accessibility and keyboard considerations in mind.

100px
auto
1
2

Flexible column width

flex supports weight, fixed length and auto. wrap=false leaves one line.

Column 1
Column 2
Column 3
Column 4

Adaptive number of columns

xs/sm/md/lg depend on the viewport, not the width of the card. Change the window width to compare layout.

Block 1
Block 2
Block 3
Block 4

Adaptive flex

Breakpoint objects can specify flex instead of span. Dimensions are changed via CSS variables Col.

Main unit
Addition

Parameters at different breakpoints

In a breakpoint object you can combine span, offset and order. gutter, align and justify Row also accept a responsive map.

Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8

Custom Grid

Change the number of columns and both spacing. The application calculates the span from the selected quantity.

Matched media queries:

After connecting the browser

Starting from sm, several thresholds can coincide simultaneously.

Monitoring breakpoint

Grid.useBreakpoint() returns a reactive breakpoint map. Subscriptions follow the component lifecycle.

First
Second

Mesh direction

Columns follow the direction of the provider. Logical intervals do not require separate styles for RTL.

Theme Row and Col
Local size 16px
Nested theme 12px

Component Grid theme

theme.components.Grid specifies Row and Col alias tokens; the nested theme and local style have their own precedence.

General md: 900px. Below the threshold there is one column, above it there are two.

First column
Second column

Isolated provider: standard md from 768px.

Standard first
Standard second

Thresholds from the general topic

screenMD changes observer Row, screenMDMin - media queries Col, including SSR without JavaScript. For comparison, an isolated standard mesh is nearby.

Draft
Adaptive column
Next line
Without transfer
General: suite; class: project-row —

Both lines use the same local class. Row and Col choose local prefixes independently; the empty line selects a generic namespace. Col service variables use a common prefix without dots, separate from the topic. The field and form data are saved.

Grid Row Prefixes

Local and global prefixCls Row, adaptive spacing and RTL. Col keeps its own classes; the draft and form data remain in place.

Planning
Development
Check
Issue

Project cards

Saved adaptive viewing grid with variable horizontal gutter.

API

Themes of the ant.design live page are mapped to the public API of the installed package. Full definitions of Props are in @woodger/antd.

Topics of official examples
ThemeExample or limitation
Basic Grid24 shares.
Grid GutterHorizontal and vertical spacing.
Column offsetEmpty shares.
Grid sortpush/pull.
TypesettingDistribution of free space.
AlignmentDifferent column heights.
OrderVisual order.
Flex StretchWeight, fixed length and auto.
ResponsiveNumber of columns by viewport.
Flex Responsiveflex in responsive object.
More responsivespan/offset/order and responsive Row.
PlaygroundNumber of columns and two spaces.
useBreakpoint HookGrid.useBreakpoint() uses the breakpoints of the nearest theme.
Row CSS prefixString prefixes, responsive gutter, RTL and form field saving; Col is connected separately.
Main Grid parameters
PropertyDescriptionTypeDefault
prefixClsFull local prefix Row. The empty string and undefined inherit the provider prefix. Col chooses its prefix independently.stringConfigProvider.prefixCls + "-row"
gutterNumber in px, CSS string or responsive map of numbers; the pair specifies the horizontal and vertical spacing.GridGutter | [GridGutter, GridGutter]0
aligntop/middle/bottom/stretch, including breakpoint.RowAlign | GridResponsive<RowAlign>CSS stretch
justifystart/end/center/space-around/space-between/space-evenly.RowJustify | GridResponsive<RowJustify>start
wrapPermission to move columns.booleantrue
childrenDirect Col inside Row.Snippet—
classRoot row class.string—
styleInline CSS of the root line.string—
nativeElementbind:nativeElement for Row and Col.HTMLDivElement—

Col

span - width from 0 to 24, 0 hides the column. offset adds beats before it; order specifies the CSS order; push/pull are shifted relative to the original position. flex accepts a number, length, auto, or CSS flex string.

xs, sm, md, lg, xl, xxl and optional xxxl accept a span or ColSize object: span, order, offset, push, pull and flex. For string span, it is safer to pass a number: responsive shorthand works with number.

Thresholds viewport

xs: up to 575px; sm: from 576px; md: from 768px; lg: from 992px; xl: from 1200px; xxl: from 1600px; xxxl: from 1920px. Values ​​sm and higher are in effect until the next override.

Semantic DOM

Row and Col create divs without any additional wrappers. Inside the Row, place a Col, and inside the Col, the contents or nested Row. CSS grid systems are based on flexbox; The table role is not assigned to these containers.

Row and Col support class/style and bind:nativeElement. Dedicated classNames/styles and ConfigProvider.grid are unavailable. Grid.useBreakpoint() observes the viewport. Use createBreakpoint to manage the connection manually.

Row.prefixCls changes the root and states of wrap, align, justify and RTL. The Col classes and its service namespace remain ant-col: the local or general Row prefix does not rename them. theme.cssVar.prefix separately specifies the namespace of theme variables.

Registration tokens

Grid does not have its own component tokens. theme.components.Grid accepts alias tokens and algorithms: for example, fontSize and fontFamily are applied to Row and Col, including with SSR. Local style takes precedence.

Thresholds are set through common theme.token: screenMD and other screen* control responsive observer Row, and screenMDMin and other screen*min control media queries Col. Change the agreed boundaries together, respecting screen*min ≤ screen* ≤ screen*max ≤ next screen*min. Col uses the provider's own CSS scope and works without JavaScript. Component overrides Grid.screen* do not change media queries.

A separate createBreakpoint() model without explicit queries uses standard thresholds. For your queries, pass them as the second argument to breakpoint.connect(window, mediaQueries). The model does not read the topic automatically.

Common tokens of the current topic
TokenCurrent value
screenXS480
screenXSMin480
screenXSMax575
screenSM576
screenSMMin576
screenSMMax767
screenMD768
screenMDMin768
screenMDMax991
screenLG992
screenLGMin992
screenLGMax1199
screenXL1200
screenXLMin1200
screenXLMax1599
screenXXL1600
screenXXLMin1600

FAQ

Why does Row extend beyond the edges of the content?

Horizontal gutter creates negative padding. Match them with the padding and width of the outer container.

Why doesn't responsiveness follow the width of the card?

Breakpoints use viewport. Dependency on container width requires a separate application solution.

Is it possible to change the order of fields using order?

The visual order will change, but Read and Tab will maintain the DOM sequence. Keep this in mind when laying out your form.

How to connect createBreakpoint with SSR?

Create a model in script, connect it to onMount and return cleanup. Until mount, the screens card remains empty.