className
and style
props. This ensures that gaps in the design system are surfaced rather than encouraging consumers to constantly apply workarounds.An example of composing a simple view leveraging some of these could be:<Card> <Heading level="4">Title</Heading> <Text>My first Braid component</Text> <Button>Click me</Button> </Card>
space
property. For example, if you wantedsmall
space between items in a Stack:<Card> <Stack space="small"> <Heading level="4">Title</Heading> <Text>My first Braid component</Text> <Button>Click me</Button> </Stack> </Card>
space
property is a responsive prop, which means that it can also accept different values for each breakpoint. For example, if you wanted small
space on mobile and medium
space on tablet and above:<Card> <Stack space={{ mobile: "small", tablet: "medium" }}> <Heading level="4">Title</Heading> <Text>My first Braid component</Text> <Button>Click me</Button> </Stack> </Card>
<Columns space="gutter" collapseBelow="tablet"> <Column> <Card> <Stack space="small"> <Heading level="4">Column 1</Heading> <Text>My first Braid component</Text> </Stack> </Card> </Column> <Column> <Card> <Stack space="small"> <Heading level="4">Column 2</Heading> <Text>My second Braid component</Text> </Stack> </Card> </Column> </Columns>
space
property is also responsive, supporting values that differ by breakpoint. For example, if you wanted xxsmall
space on mobile and gutter
space on tablet and above:<Columns space={{ mobile: "xxsmall", tablet: "gutter" }} collapseBelow="tablet" > <Column> <Card> <Stack space="small"> <Heading level="4">Column 1</Heading> <Text>My first Braid component</Text> </Stack> </Card> </Column> <Column> <Card> <Stack space="small"> <Heading level="4">Column 2</Heading> <Text>My second Braid component</Text> </Stack> </Card> </Column> </Columns>
<Box background="brand" boxShadow="large" padding="large"> <Text>My first Braid component</Text> </Box>
display
responsively:<Box display={{ mobile: "flex", tablet: "block" }}> <Heading level="2">Flex on small screen</Heading> <Heading level="2">Block on large screen</Heading> </Box>
component
prop.For example, in order to render a semantic fieldset
element without the native browser styles:css
export:import { vars } from "braid-design-system/css"
className
and style
), Box is the one exception. However, you should take care to ensure that custom classes on Box only use styles that are not available via its prop interface.For example, if you wanted to render an element as display: flex
, but with a custom, responsive flex-basis
value:// myComponent.css.ts import { style } from "@vanilla-extract/css" import { vars, responsiveStyle } from "braid-design-system/css" export const root = style( responsiveStyle({ mobile: { flexBasis: vars.space.small }, tablet: { flexBasis: vars.space.medium }, desktop: { flexBasis: vars.space.large }, wide: { flexBasis: vars.space.xlarge }, }) )
.css.ts
extension), the vars
object will be available for autocompletion and type checking within your editor.// myComponent.ts import * as styles from "./myComponent.css" export default function MyComponent() { return ( <Box display="flex" className={styles.root}> <Text>My first Braid component</Text> </Box> ) }