Layout

Container

Keeps content at a readable width, centred, with room at the sides on small screens.

#layout#no-js

Demo

Preview
size="sm"
size="md"
size="lg"

Each is centred at its width, at most; the dashed lines are the container's padding edge.

Get it

It needs theme.qwe, as every component does; or take the whole kit, quillo-ui.qwe. Each component brings its own styles to the pages that show it.

$ curl -O https://quillolang.org/components/ui/theme.qwe$ curl -O https://quillolang.org/components/ui/container.qwe
main.qwe
import ui/theme.qwe use theme_cssuse ui/container.qweroute GET / = <html><head><style>{theme_css}</style></head><body class="ui-root">...</body></html>

Example

The code of the preview above.

demos/container.qwe
view ContainerDemo() =    <div.demo-stack>        {for s in ["sm", "md", "lg"] =>            <div style="background: var(--ui-subtle); border-radius: var(--ui-radius-sm)">                <Container size={s}>                    <div style="padding: 10px 0; border-inline: 1px dashed var(--ui-strong); text-align: center; font-size: 13px; color: var(--ui-muted)">                        size="{s}"                    </div>                </Container>            </div>}        <p.demo-note>Each is centred at its width, at most; the dashed lines are the container's padding edge.</p>    </div>

Source

ui/container.qwe
// Container: keeps a page's content at a readable width, centred, with room at// the sides on small screens.////   <Container><h1>Settings</h1> ... </Container>//   <Container size="sm"> ... a sign-in form ... </Container>//// size: "sm" (640px), "md" (860px), "lg" (1140px, default) or "full" (no limit).// pad: false leaves out the side padding (16px, 24px on wider screens).import ui/theme.qwe use ui_clslet container_css = css`.ui-container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 16px; }.ui-container-sm { max-width: 640px; }.ui-container-md { max-width: 860px; }.ui-container-full { max-width: none; }.ui-container-flush { padding-inline: 0; }@media (min-width: 640px) { .ui-container:not(.ui-container-flush) { padding-inline: 24px; } }`view Container(size: str = "lg", pad: bool = true, class: str? = null, children) {    style global container_css    <div class={ui_cls(["ui-container", size != "lg" && `ui-container-${size}`, !pad && "ui-container-flush", class])}>        {children}    </div>}
Thread
95Useful? Like it, or add to its thread below.

Thread 0 posts

On Container: questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.