Skip to content

Flex Layout

Flexbox-based layout component, providing flexible control over direction, alignment, wrapping, and spacing. Deeply integrated with BrConfigProvider, supporting responsive properties and global theme configuration.

Basic Usage

Quickly build layouts using gap, justify, and align props.

Example

Vertical Layout

Set direction="col" to switch to vertical layout.

Example

Responsive Layout

Core props like direction, gap, justify, align support responsive object configuration. You can set different values for different breakpoints (sm, md, lg, xl, 2xl).

Mobile: Column & Small Gap | Tablet+: Row & Large Gap

Item A
Item B
Item C
Example

Theming & Tokens

The gap prop of BrFlex supports referencing sizing tokens defined in BrConfigProvider. By configuring BrConfigProvider globally or locally, you can unify spacing standards.

In the following example, we define a sizing token named xl (paddingX: 4rem) and use it directly in BrFlex via gap="xl".

Using global token 'xl' (defined as 4rem) for gap:

Example

API

BrFlex Props

Prop NameTypeDefaultDescription
asstring'div'The HTML tag or component to render
directionResponsiveProp<FlexDirection>'row'Flex direction. Options: row, row-reverse, col, col-reverse
wrapResponsiveProp<FlexWrap>'nowrap'Flex wrap. Options: nowrap, wrap, wrap-reverse
justifyResponsiveProp<FlexJustify>'start'Justify content. Options: start, end, center, between, around, evenly
alignResponsiveProp<FlexAlign>'start'Align items. Options: start, end, center, baseline, stretch
gapResponsiveProp<string | number>-Gap spacing. Supports Tailwind numbers (e.g. '4') or ConfigProvider Tokens (e.g. 'md')
gapXResponsiveProp<string | number>-Horizontal gap
gapYResponsiveProp<string | number>-Vertical gap
growbooleanfalseWhether to grow (flex-grow)
shrinkbooleanfalseWhether to shrink (flex-shrink)
basisstring | number-Base size (flex-basis)

Type Explanation

ResponsiveProp<T>

Properties can be a direct value T, or an object containing breakpoints:

ts
type ResponsiveProp<T> = T | {
  base?: T
  sm?: T
  md?: T
  lg?: T
  xl?: T
  '2xl'?: T
  [key: string]: T | undefined
}

Example:

vue
<!-- Simple value -->
<BrFlex direction="row" />

<!-- Responsive object -->
<BrFlex
  :direction="{ base: 'col', md: 'row' }"
  :gap="{ base: '2', lg: '4' }"
/>