Container
StableA centered column with a set width and margins on the sides.
Also known as wrapper, max width, center
Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.
Chat width
<Container size="chat">
<Stack>…thread…</Stack>
</Container>This width fits about 70 to 75 characters a line at normal text size.
When to use it
A centered column with a maximum width and side margins. Long lines are hard to read, so the chat width keeps a conversation at a comfortable line length.
Made of: Side margins · Column with a maximum width
Do and avoid
Your hotel is booked for 3 nights. You can cancel for free until Friday.
Your hotel is booked for 3 nights. You can cancel for free until Friday.
Do
- Use chat width for the conversation and the message box so they line up.
- Use page width for settings and documentation.
- Use the main element once per page.
- Let side margins grow on larger screens.
Avoid
- Do not put containers inside containers.
- Do not hard-code widths in components.
- Do not use full width for running text.
- Do not let chat lines run past about 80 characters.
On a phone
- On a phone it fills the width with a 16px side margin, and the width presets do not apply because they are all wider than a phone.
- Use flush when content such as an image must reach the screen edge.
- It adds no safe-area padding, so add that yourself where content sits against a notch or the bottom bar.
Seen in products
- GOV.UK uses a fixed page width and a tablet screen size.
- Material 3 uses bigger margins on bigger screens (seen in snippets).
- Accessibility guidelines ask for lines of no more than 80 characters.
Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "chat" | "home" | "page" | "full" | "page" | Max-width preset. chat 768px, home 680px, page 1120px, full uncapped. |
| flush | boolean | false | Removes the side margins for content that bleeds to the edge. |
| as | "div" | "main" | "section" | "article" | "header" | "footer" | "nav" | "div" | Element to render. |
"Show code under the preview gives the code for the example on the stage."
In Figma
In Figma, one Container switches all of this from its properties panel, across 8 variants. Each property sets the React prop beside it, so design and code use the same names.
| Figma property | React | Values |
|---|---|---|
| Size | size | Chat, Home, Page, Full |
| Flush | flush | On or off |
Tokens
Change one of these and every part that uses it follows.
--w-chat--w-home--w-page--margin
Built in
- It adds no meaning of its own: it renders the element you choose.
- Side margins keep text off the screen edge at every size, unless you turn them off with flush.
- The chat and home widths keep lines of text to a readable length.
What you need to do
- Set as to main for the main area of the page, and use main only once per page.
- Do not use the full width for running text, because very long lines are hard to read.
Built toward WCAG 2.2 AA and checked automatically; no independent audit yet. Read the accessibility guide