Custom breakpoints
Name your own breakpoints (phone … wide), generate CSS and TypeScript declarations, and keep Tailwind in sync.
Responsive props default to Tailwind v4's breakpoints (sm 40rem, md 48rem, lg 64rem, xl 80rem,
2xl 96rem). An application can replace or extend them in neshel.config.ts. The CLI then
generates the CSS for those breakpoints and the TypeScript declarations that make the names
type-check. Nothing about breakpoints is evaluated in the browser.
End-to-end example: phone … wide
1. Configure
import { defineConfig } from "@neshel-ui/config";
export default defineConfig({
breakpoints: {
mode: "replace",
values: {
phone: "30rem",
phoneXL: "40rem",
tablet: "48rem",
laptop: "64rem",
desktop: "80rem",
wide: "96rem",
},
tailwind: true,
},
output: "./src/neshel.generated.css",
types: "./src/neshel.generated.d.ts",
});2. Generate
pnpm exec neshel generate
# neshel: wrote src/neshel.generated.css (2 themes, 6 breakpoints, layout + typography + components, 0 warnings).
# neshel: wrote src/neshel.generated.d.ts.The stylesheet includes complete layout, typography and components rules for your breakpoints
(for every package installed next to the CLI), the tokens, and — with tailwind: true — a Tailwind
@theme block:
@layer components.neshel {
:root { --neshel-breakpoints: "phone phoneXL tablet laptop desktop wide"; }
@media (min-width: 48rem) {
.neshel-tablet-gap-4 { gap: calc(var(--neshel-spacing) * 4); }
}
}
@theme {
--breakpoint-*: initial;
--breakpoint-phone: 30rem;
--breakpoint-phoneXL: 40rem;
--breakpoint-tablet: 48rem;
--breakpoint-laptop: 64rem;
--breakpoint-desktop: 80rem;
--breakpoint-wide: 96rem;
}// Generated by "neshel generate" from neshel.config.ts; do not edit.
export {};
declare module "@neshel-ui/config" {
interface BreakpointRegistry {
readonly names: "phone" | "phoneXL" | "tablet" | "laptop" | "desktop" | "wide";
}
}3. Wire it up
- Add
src/neshel.generated.d.tstotsconfig.json(include). It works withBundlerandNodeNextresolution. - Import the generated stylesheet after the package stylesheets (or instead of them):
@import "tailwindcss";
@import "@neshel-ui/config/tailwind.css";
@import "@neshel-ui/layout/styles.css";
@import "@neshel-ui/typography/styles.css";
@import "@neshel-ui/components/styles.css";
@import "./neshel.generated.css";4. Use the names
import { Button } from "@neshel-ui/components";
import { Grid, Stack } from "@neshel-ui/layout";
import { Heading } from "@neshel-ui/typography";
export function Products() {
return (
<Stack space={{ base: "4", tablet: "8" }}>
<Heading size={{ base: "xl", laptop: "3xl", wide: "5xl" }}>Products</Heading>
<Grid columns={{ base: 1, phoneXL: 2, laptop: 3, wide: 4 }} space="4">
<Button size={{ base: "sm", tablet: "md" }}>Add product</Button>
</Grid>
</Stack>
);
}With replace, md is now a type error, and Tailwind utilities such as tablet:flex switch at
exactly the same widths as the props.
extend versus replace
| Mode | Names available | Use when |
|---|---|---|
extend | sm md lg xl 2xl plus your names | You want one or two extra thresholds |
replace | only your names | Your design system has its own breakpoint scale |
extend cannot redefine a default name, and every width must be distinct — so phoneXL: "40rem"
(equal to sm) only works in replace mode. Example of extend:
import { defineConfig } from "@neshel-ui/config";
export default defineConfig({
breakpoints: { mode: "extend", values: { phone: "30rem", tablet: "52rem" } },
});Rules
- Names: lower camelCase (
phoneXL), unique ignoring case, not reserved (base, Neshel class prefixes, Tailwind variant names such asdarkorprint). At most 12 breakpoints. - Widths:
remonly, distinct. Output is always sorted by width. baseis optional in every responsive object: below the first written key the property is simply not set (the component default applies).
Responsive inheritance and static values
<Stack space="4">
<Grid columns={{ base: 1, md: 3 }} space={{ md: "6" }}>
<Box>Static spacing on the Stack; responsive columns and spacing on the Grid.</Box>
</Grid>
</Stack>- A plain value (
space="4") applies at every width. - An object cascades upwards:
{ base: 1, md: 3 }is 1 untilmd, then 3 — also atlg,xl,2xl. { md: "6" }withoutbase: no gap belowmd.
Unsupported breakpoint names
The runtime has no configuration, so it cannot know your names. Malformed keys ({ "Tablet!": … })
throw. A well-formed but unknown key ({ tablett: … }) cannot be rejected at runtime: TypeScript
rejects it when the generated declarations are included, and in the browser Neshel logs one
warning per unknown key by comparing it with --neshel-breakpoints from the loaded stylesheet.
Server rendering never warns and markup never depends on the configuration.
Tailwind CSS v4 and plain CSS
- With Tailwind: set
tailwind: trueand import the generated file from your Tailwind entry CSS.replacefirst clears Tailwind's default breakpoints (--breakpoint-*: initial). - Without Tailwind: leave
tailwindunset. The generated file is then plain CSS that any bundler (or none) can load.
How changes propagate
neshel.config.ts ──neshel generate──▶ neshel.generated.css (tokens + package rules + @theme)
└─▶ neshel.generated.d.ts (BreakpointRegistry augmentation)Edit the configuration → run neshel generate (your dev/build scripts do it) → the bundler picks
up the new CSS and TypeScript sees the new names. In CI, neshel generate --check fails when either
file is stale. Unchanged output is never rewritten, so file watchers do not loop.