Components
Responsive Container
Constrains content with breakpoint-aware widths and gutters.
Installation
$ npx veil-ui@latest add responsive-containerUsage
import { ResponsiveContainer } from "@/components/ui/responsive-container";
<ResponsiveContainer maxWidth="md" gutter="lg">
<Page />
</ResponsiveContainer>;Examples
Sizes
maxWidth="sm"
maxWidth="md"
maxWidth="lg"
Gutters
Wider gutters on larger screens.
Fluid
Fluid width, no centering.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| maxWidth | "xs" | "sm" | "md" | "lg" | "xl" | "full" | "lg" | Max width token: sm to 7xl, or none. |
| gutter | "none" | "sm" | "md" | "lg" | "md" | Horizontal padding that grows on larger screens. |
| fluid | boolean | false | Skip auto-centering. |
| ...props | React.ComponentProps<"div"> | — | All native div attributes. |
Accessibility
- Presentational wrapper; it adds no roles.
- Resize the viewport to check that content reflows without horizontal scrolling.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add responsive-container --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed } from "vue";
import { cn } from "@/lib/utils";
const widths = {
xs: "max-w-sm",
sm: "max-w-xl",
md: "max-w-3xl",
lg: "max-w-5xl",
xl: "max-w-7xl",
full: "max-w-none",
} as const;
const gutters = {
none: "px-0",
sm: "px-2 sm:px-4",
md: "px-4 sm:px-6",
lg: "px-6 sm:px-8",
} as const;
const props = withDefaults(
defineProps<{
maxWidth?: keyof typeof widths;
gutter?: keyof typeof gutters;
fluid?: boolean;
class?: string;
}>(),
{ maxWidth: "lg", gutter: "md", fluid: false },
);
const classes = computed(() =>
cn(
"w-full",
!props.fluid && "mx-auto",
widths[props.maxWidth],
gutters[props.gutter],
props.class,
),
);
</script>
<template>
<div data-slot="responsive-container" :data-max-width="maxWidth" :class="classes">
<slot />
</div>
</template>