DocsPluginsShowcaseReleases
npmStar us on GitHub

Getting Started

IntroductionInstallationProject StructureLayouts and PagesLinking and Navigating

Routing

Folder-Based RoutingFile-Based RoutingDynamic RoutesParallel RoutesIntercepting RoutesCatch-All RoutesMDX & Markdown Pages

Special Files

Loading UIError BoundariesTemplateDefaultNot Found

Data Fetching

LoadersActionsAccessing Route Data

Metadata

Metadata & SEOOpen Graph & TwitterIcons & Favicons

API Routes

API Routes OverviewPlain Function HandlersHono IntegrationDynamic API Routes

Environment Variables

OverviewPrefixes & Client ExposureUsing in API Routes

Styling

CSS OverviewTailwind CSSCSS Modules

Platforms

WebWindowsmacOSLinuxAndroidiOS

Deployment

Deployment OverviewProduction ServerStatic ExportHosting Providers

A native React framework for building cross-platform applications from a single codebase.

Resources

  • Documentation
  • Plugins
  • Showcase
  • Releases

Community

  • GitHub Discussions
  • Reddit
  • Discord
  • LinkedIn

More

  • npm
  • GitHub
  • Issues
  • License

© 2026 Bini Cooperation.

Plain CSS

Use plain CSS in Bini.js - import only what you need, where you need it.

Plain CSS in Bini.js

Bini.js works with plain .css files out of the box. Import a .css file and it loads. This page covers plain CSS only.

>_Terminal
$ npx create-bini-app@latest my-app --none

Or run the interactive prompt and choose None for styling:

>_Terminal
◆
Styling solution?
○ Tailwind CSS
○ CSS Modules
● None
↑/↓ to navigate • Enter: confirm

Global CSS

Put base styles, resets, and variables in a global stylesheet. Import it once in your root layout:

src/app/globals.css
/* src/app/globals.css - base reset and variables */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --border: #e5e5e5;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
src/app/layout.tsx
// src/app/layout.tsx - root layout
import './globals.css'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}
Keep global CSS small: resets, variables, and styles that every page needs. Import styles for a specific route or component next to the file that uses them.

CSS for Specific Routes

Import CSS in the route that needs it. That way, pages that do not use the styles never load them. Each route can have its own stylesheet:

src/app/(marketing)/page.css
/* src/app/(marketing)/page.css - only loaded for marketing route */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
src/app/(marketing)/page.tsx
// src/app/(marketing)/page.tsx
import './page.css'

export default function MarketingPage() {
  return (
    <div className="hero">
      <h1>Welcome to Bini.js</h1>
      <p>Build fast, ship faster</p>
    </div>
  )
}
src/app/dashboard/page.css
/* src/app/dashboard/page.css - only for dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding-right: 1.5rem;
}
src/app/dashboard/layout.tsx
// src/app/dashboard/layout.tsx - layout level CSS for dashboard
import './page.css'

export default function DashboardLayout({ children }: { children: React.ReactNode }) {
  return <div className="dashboard-grid">{children}</div>
}
Each route's CSS is only downloaded when that route is visited. A visitor on / will not download dashboard/page.css. Import CSS in the page or layout that uses it.

Blog Layout Example - Scoped CSS

When a layout imports a stylesheet, that CSS applies only to routes inside the layout's folder. Here, blog.css is imported in the blog layout:

src/app/blog/blog.css
/* src/app/blog/blog.css - only for /blog/* */
.blog-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
  line-height: 1.7;
}

.blog-wrapper h1 {
  font-size: 2rem;
  font-weight: 700;
}

.blog-wrapper article {
  color: var(--text);
}
src/app/blog/layout.tsx
// src/app/blog/layout.tsx - import here, scoped to /blog only
import './blog.css'

export default function BlogLayout({ children }: { children: React.ReactNode }) {
  return <div className="blog-wrapper">{children}</div>
}
Gets blog.cssLoaded
/blog
/blog/my-post
/blog/category/tech
Does NOT get blog.cssNot loaded
/
/dashboard
/about
/docs
With blog.css imported in src/app/blog/layout.tsx, only pages under /blog load it. If you import it in the root layout instead, every page loads it.

Component CSS

Keep a plain .css file next to a reusable component. You do not need CSS Modules for this. Just use clear class names so styles do not clash:

src/app/components/Button.css
/* src/app/components/Button.css */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-primary {
  background: black;
  color: white;
}

.btn-primary:hover {
  background: #222;
}
src/app/components/Button.tsx
// src/app/components/Button.tsx
import type { ButtonHTMLAttributes, ReactNode } from 'react'
import './Button.css'

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: 'primary' | 'secondary'
  children: ReactNode
}

export function Button({ variant = 'primary', children, ...props }: ButtonProps) {
  return <button className={`btn btn-${variant}`} {...props}>{children}</button>
}
If you want class names that cannot clash with other files, use CSS Modules (.module.css). With plain CSS, prefix your class names: btn-, card-, and so on.

External Stylesheets

When you import CSS from an npm package, put the import in the route that uses it:

src/app/docs/page.tsx
// src/app/docs/page.tsx - only docs needs syntax highlighting
import 'prismjs/themes/prism.css'

export default function DocsPage() {
  return <article>...</article>
}
src/app/blog/page.tsx
// src/app/blog/page.tsx - only blog needs markdown styles
import './markdown.css'

export default function BlogPage() {
  return <div className="markdown-body">...</div>
}
Do not import external CSS in the root layout if only one route needs it. Import it in that route or its layout so other pages stay lean.

CSS Ordering

CSS applies in the order you import it. Keep a consistent order so later rules override earlier ones the way you expect:

src/app/layout.tsx
// layout.tsx - order matters
import './globals.css'      // 1. Base reset and variables first
import './theme.css'        // 2. Theme and utilities
// Route or component CSS comes after, imported inside page.tsx or component.tsx
src/app/dashboard/page.tsx
// src/app/dashboard/page.tsx
import './page.css'  // 3. Route-specific CSS - loaded only for this route

export default function DashboardPage() {
  return <div className="dashboard">...</div>
}
Import global CSS first, then layout CSS, then route CSS, then component CSS. That keeps overrides predictable.

CSS Variables

CSS variables let you define a value once and reuse it everywhere. Define them in global CSS with :root, then read them with var(--name) in any rule:

src/app/globals.css
/* src/app/globals.css */
:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --border: #e5e5e5;
  --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #fafafa;
    --border: #262626;
  }
}

body {
  background: var(--bg);
  color: var(--text);
}
src/app/components/Card.css
/* Use the variables in component CSS */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

Sass/SCSS

Vite supports Sass once you install the sass package. Import a .scss file the same way you import a .css file:

>_Terminal
$ npm install -D sass
src/app/dashboard/page.scss
/* src/app/dashboard/page.scss - only for dashboard */
.dashboard {
  display: grid;
  gap: 1rem;

  .card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);

    &:hover {
      border-color: black;
    }
  }
}
src/app/dashboard/page.tsx
// src/app/dashboard/page.tsx
import './page.scss'  // only dashboard loads this

export default function DashboardPage() {
  return <div className="dashboard">...</div>
}

CSS-in-JS Alternative

If you prefer CSS-in-JS, install the library and use it in the components that need it:

>_Terminal
$ npm install styled-components
src/app/components/StyledButton.tsx
// src/app/components/StyledButton.tsx
import type { ReactNode } from 'react'
import styled from 'styled-components'

const Button = styled.button`
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: black;
  color: white;
`

export function StyledButton({ children }: { children: ReactNode }) {
  return <Button>{children}</Button>
}
For most projects, plain CSS imported per route is simpler and faster. Reach for CSS-in-JS when you need styles that change based on component props.

CSS Modules

Scoped class names with .module.css.

Tailwind CSS

Utility-first styling with Tailwind.

Layouts and Pages

Where to import CSS in the app directory.

Using in API Routes

Read env vars from Hono handlers.

Was this helpful?
PreviousUsing in API Routes
NextTailwind CSS

On this page

  • Plain CSS in Bini.js
  • Global CSS
  • CSS for Specific Routes
  • Component CSS
  • External Stylesheets
  • CSS Ordering
  • CSS Variables
  • Sass/SCSS
  • CSS-in-JS Alternative
Edit this page on GitHub

Plain CSS

Use plain CSS in Bini.js - import only what you need, where you need it.

Plain CSS in Bini.js

Bini.js works with plain .css files out of the box. Import a .css file and it loads. This page covers plain CSS only.

>_Terminal
$ npx create-bini-app@latest my-app --none

Or run the interactive prompt and choose None for styling:

>_Terminal
◆
Styling solution?
○ Tailwind CSS
○ CSS Modules
● None
↑/↓ to navigate • Enter: confirm

Global CSS

Put base styles, resets, and variables in a global stylesheet. Import it once in your root layout:

src/app/globals.css
/* src/app/globals.css - base reset and variables */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --border: #e5e5e5;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
src/app/layout.tsx
// src/app/layout.tsx - root layout
import './globals.css'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}
Keep global CSS small: resets, variables, and styles that every page needs. Import styles for a specific route or component next to the file that uses them.

CSS for Specific Routes

Import CSS in the route that needs it. That way, pages that do not use the styles never load them. Each route can have its own stylesheet:

src/app/(marketing)/page.css
/* src/app/(marketing)/page.css - only loaded for marketing route */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
src/app/(marketing)/page.tsx
// src/app/(marketing)/page.tsx
import './page.css'

export default function MarketingPage() {
  return (
    <div className="hero">
      <h1>Welcome to Bini.js</h1>
      <p>Build fast, ship faster</p>
    </div>
  )
}
src/app/dashboard/page.css
/* src/app/dashboard/page.css - only for dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding-right: 1.5rem;
}
src/app/dashboard/layout.tsx
// src/app/dashboard/layout.tsx - layout level CSS for dashboard
import './page.css'

export default function DashboardLayout({ children }: { children: React.ReactNode }) {
  return <div className="dashboard-grid">{children}</div>
}
Each route's CSS is only downloaded when that route is visited. A visitor on / will not download dashboard/page.css. Import CSS in the page or layout that uses it.

Blog Layout Example - Scoped CSS

When a layout imports a stylesheet, that CSS applies only to routes inside the layout's folder. Here, blog.css is imported in the blog layout:

src/app/blog/blog.css
/* src/app/blog/blog.css - only for /blog/* */
.blog-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
  line-height: 1.7;
}

.blog-wrapper h1 {
  font-size: 2rem;
  font-weight: 700;
}

.blog-wrapper article {
  color: var(--text);
}
src/app/blog/layout.tsx
// src/app/blog/layout.tsx - import here, scoped to /blog only
import './blog.css'

export default function BlogLayout({ children }: { children: React.ReactNode }) {
  return <div className="blog-wrapper">{children}</div>
}
Gets blog.cssLoaded
/blog
/blog/my-post
/blog/category/tech
Does NOT get blog.cssNot loaded
/
/dashboard
/about
/docs
With blog.css imported in src/app/blog/layout.tsx, only pages under /blog load it. If you import it in the root layout instead, every page loads it.

Component CSS

Keep a plain .css file next to a reusable component. You do not need CSS Modules for this. Just use clear class names so styles do not clash:

src/app/components/Button.css
/* src/app/components/Button.css */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-primary {
  background: black;
  color: white;
}

.btn-primary:hover {
  background: #222;
}
src/app/components/Button.tsx
// src/app/components/Button.tsx
import type { ButtonHTMLAttributes, ReactNode } from 'react'
import './Button.css'

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: 'primary' | 'secondary'
  children: ReactNode
}

export function Button({ variant = 'primary', children, ...props }: ButtonProps) {
  return <button className={`btn btn-${variant}`} {...props}>{children}</button>
}
If you want class names that cannot clash with other files, use CSS Modules (.module.css). With plain CSS, prefix your class names: btn-, card-, and so on.

External Stylesheets

When you import CSS from an npm package, put the import in the route that uses it:

src/app/docs/page.tsx
// src/app/docs/page.tsx - only docs needs syntax highlighting
import 'prismjs/themes/prism.css'

export default function DocsPage() {
  return <article>...</article>
}
src/app/blog/page.tsx
// src/app/blog/page.tsx - only blog needs markdown styles
import './markdown.css'

export default function BlogPage() {
  return <div className="markdown-body">...</div>
}
Do not import external CSS in the root layout if only one route needs it. Import it in that route or its layout so other pages stay lean.

CSS Ordering

CSS applies in the order you import it. Keep a consistent order so later rules override earlier ones the way you expect:

src/app/layout.tsx
// layout.tsx - order matters
import './globals.css'      // 1. Base reset and variables first
import './theme.css'        // 2. Theme and utilities
// Route or component CSS comes after, imported inside page.tsx or component.tsx
src/app/dashboard/page.tsx
// src/app/dashboard/page.tsx
import './page.css'  // 3. Route-specific CSS - loaded only for this route

export default function DashboardPage() {
  return <div className="dashboard">...</div>
}
Import global CSS first, then layout CSS, then route CSS, then component CSS. That keeps overrides predictable.

CSS Variables

CSS variables let you define a value once and reuse it everywhere. Define them in global CSS with :root, then read them with var(--name) in any rule:

src/app/globals.css
/* src/app/globals.css */
:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --border: #e5e5e5;
  --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #fafafa;
    --border: #262626;
  }
}

body {
  background: var(--bg);
  color: var(--text);
}
src/app/components/Card.css
/* Use the variables in component CSS */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

Sass/SCSS

Vite supports Sass once you install the sass package. Import a .scss file the same way you import a .css file:

>_Terminal
$ npm install -D sass
src/app/dashboard/page.scss
/* src/app/dashboard/page.scss - only for dashboard */
.dashboard {
  display: grid;
  gap: 1rem;

  .card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);

    &:hover {
      border-color: black;
    }
  }
}
src/app/dashboard/page.tsx
// src/app/dashboard/page.tsx
import './page.scss'  // only dashboard loads this

export default function DashboardPage() {
  return <div className="dashboard">...</div>
}

CSS-in-JS Alternative

If you prefer CSS-in-JS, install the library and use it in the components that need it:

>_Terminal
$ npm install styled-components
src/app/components/StyledButton.tsx
// src/app/components/StyledButton.tsx
import type { ReactNode } from 'react'
import styled from 'styled-components'

const Button = styled.button`
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: black;
  color: white;
`

export function StyledButton({ children }: { children: ReactNode }) {
  return <Button>{children}</Button>
}
For most projects, plain CSS imported per route is simpler and faster. Reach for CSS-in-JS when you need styles that change based on component props.

CSS Modules

Scoped class names with .module.css.

Tailwind CSS

Utility-first styling with Tailwind.

Layouts and Pages

Where to import CSS in the app directory.

Using in API Routes

Read env vars from Hono handlers.

Was this helpful?
PreviousUsing in API Routes
NextTailwind CSS

On this page

  • Plain CSS in Bini.js
  • Global CSS
  • CSS for Specific Routes
  • Component CSS
  • External Stylesheets
  • CSS Ordering
  • CSS Variables
  • Sass/SCSS
  • CSS-in-JS Alternative
Edit this page on GitHub