Saltearse al contenido

Customizing StudioCMS UI

Esta página aún no está disponible en tu idioma.

StudioCMS UI is designed on top of CSS variables, which makes it easy to customize the look of the components to match your brand. You can customize the colors, typography, radii, and more. All customization is done with a custom CSS file that you can provide to the UI integration:

astro.config.mjs
import { defineConfig } from 'astro/config';
import ui from '@studiocms/ui';
export default defineConfig({
integrations: [
ui({
customCss: './path/to/custom.css'
})
]
});

In that file, you can override the CSS variables to change the look of the components. If you wanted to overwrite the primary color, it’d look like this:

custom.css
:root {
--primary-base: 0 0% 100%;
--primary-hover: 0 0% 80%;
--primary-active: 0 0% 90%;
}
[data-theme='light'] :root {
--primary-base: 0 0% 0%;
--primary-hover: 0 0% 20%;
--primary-active: 0 0% 10%;
}

If you make significant changes to the colors, remember to also adjust the light theme.

Below, you will find all the CSS variables used in StudioCMS UI. Always make sure to provide them as HSL values without commas. You can use them in your CSS like this: background-color: hsl(var(--background-base));.

If you want to disable the CSS injection, you can do so by setting the noInjectCSS option to true:

astro.config.mjs
import {
function defineConfig<const TLocales extends Locales = never, const TDriver extends SessionDriverName = never>(config: AstroUserConfig<TLocales, TDriver>): AstroUserConfig<TLocales, TDriver>

See the full Astro Configuration API Documentation https://astro.build/config

defineConfig
} from 'astro/config';
import
function ui(options?: Options): AstroIntegration
ui
from '@studiocms/ui';
export default
defineConfig<never, never>(config: AstroUserConfig<never, never>): AstroUserConfig<never, never>

See the full Astro Configuration API Documentation https://astro.build/config

defineConfig
({
AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never>.integrations?: (false | AstroIntegration | (false | AstroIntegration | null | undefined)[] | null | undefined)[]

@nameintegrations

@description

Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown).

Read our Integrations Guide for help getting started with Astro Integrations.

import react from '@astrojs/react';
import tailwind from '@astrojs/tailwind';
{
// Example: Add React + Tailwind support to Astro
integrations: [react(), tailwind()]
}

integrations
: [
function ui(options?: Options): AstroIntegration
ui
({
noInjectCSS?: boolean

Disable CSS Generation and require manual addition of the global CSS

@example

import 'studiocms:ui/global-css';

noInjectCSS
: true,
})
]
});

You can then include the CSS in your project manually. This is useful if you want to mix StudioCMS UI with other CSS frameworks, or if you are using the UI styling only for a subset of your components.

src/layouts/SUILayout.astro
---
// Using the virtual module to import the CSS file (recommended)
import "studiocms:ui/global-css";
// Alternatively, import the CSS file directly from the package
import "@studiocms/ui/css/global.css";
---

You can edit the colors in your own project during development using the dev toolbar. In the toolbar, you will find a tab with the StudioCMS logo on it. Once clicked it will reveal a few color pickers and inputs you can use to adjust various variables. You can copy your changes to your clipboard after you are done.

Dark Mode
VariableDescriptionDefault
--background-baseBase background color0 0% 6%
--background-step-1Background color step 10 0% 8%
--background-step-2Background color step 20 0% 10%
--background-step-3Background color step 30 0% 14%
--text-normalNormal text color0 0% 100%
--text-mutedMuted text color0 0% 54%
--text-invertedInverted text color0 0% 0%
--borderBorder color240 5% 17%
--shadowShadow color0 0% 0%
--default-baseDefault color base0 0% 14%
--default-hoverDefault color hover0 0% 21%
--default-activeDefault color active0 0% 15%
--primary-basePrimary color base259 83% 73%
--primary-hoverPrimary color hover259 77% 78%
--primary-activePrimary color active259 73% 67%
--success-baseSuccess color base142 71% 46%
--success-hoverSuccess color hover142 72% 61%
--success-activeSuccess color active142 87% 52%
--warning-baseWarning color base48 96% 53%
--warning-hoverWarning color hover48 97% 70%
--warning-activeWarning color active48 100% 61%
--danger-baseDanger color base339 97% 31%
--danger-hoverDanger color hover337 98% 37%
--danger-activeDanger color active337 88% 32%
--info-baseInfo color base217 92% 52%
--info-hoverInfo color hover214 95% 58%
--info-activeInfo color active214 85% 52%
--mono-baseMono color base0 0% 100%
--mono-hoverMono color hover0 0% 90%
--mono-activeMono color active0 0% 95%
Light Mode
VariableDescriptionDefault
--background-baseBase background color0 0% 97%
--background-step-1Background color step 10 0% 90%
--background-step-2Background color step 20 0% 85%
--background-step-3Background color step 30 0% 80%
--text-normalNormal text color0 0% 0%
--text-mutedMuted text color0 0% 24%
--text-invertedInverted text color0 0% 100%
--borderBorder color263 5% 68%
--shadowShadow color0 0% 65%
--default-baseDefault color base0 0% 74%
--default-hoverDefault color hover0 0% 81%
--default-activeDefault color active0 0% 91%
--primary-basePrimary color base259 85% 61%
--primary-hoverPrimary color hover259 78% 56%
--primary-activePrimary color active259 71% 50%
--success-baseSuccess color base142 59% 47%
--success-hoverSuccess color hover142 62% 56%
--success-activeSuccess color active142 87% 59%
--warning-baseWarning color base48 92% 46%
--warning-hoverWarning color hover48 88% 43%
--warning-activeWarning color active48 85% 40%
--danger-baseDanger color base339 97% 31%
--danger-hoverDanger color hover337 98% 37%
--danger-activeDanger color active337 88% 45%
--info-baseInfo color base217 92% 52%
--info-hoverInfo color hover214 95% 58%
--info-activeInfo color active214 85% 52%
--mono-baseMono color base0 0% 0%
--mono-hoverMono color hover0 0% 10%
--mono-activeMono color active0 0% 5%
Non-Themed Color Variables
VariableDescriptionDefault
--text-lightLight text color0 0% 100%
--text-darkDark text color0 0% 0%
--default-flatDefault flat colorvar(--default-base) / 0.5
--default-flat-hoverDefault flat hover colorvar(--default-base) / 0.75
--default-flat-activeDefault flat active colorvar(--default-base) / 0.85
--primary-flatPrimary flat colorvar(--primary-base) / 0.1
--primary-flat-hoverPrimary flat hover colorvar(--primary-base) / 0.25
--primary-flat-activePrimary flat active colorvar(--primary-base) / 0.35
--success-flatSuccess flat colorvar(--success-base) / 0.1
--success-flat-hoverSuccess flat hover colorvar(--success-base) / 0.25
--success-flat-activeSuccess flat active colorvar(--success-base) / 0.35
--warning-flatWarning flat colorvar(--warning-base) / 0.1
--warning-flat-hoverWarning flat hover colorvar(--warning-base) / 0.25
--warning-flat-activeWarning flat active colorvar(--warning-base) / 0.35
--danger-flatDanger flat colorvar(--danger-base) / 0.1
--danger-flat-hoverDanger flat hover colorvar(--danger-base) / 0.25
--danger-flat-activeDanger flat active colorvar(--danger-base) / 0.35
--info-flatInfo flat colorvar(--info-base) / 0.1
--info-flat-hoverInfo flat hover colorvar(--info-base) / 0.25
--info-flat-activeInfo flat active colorvar(--info-base) / 0.35
Radius Variables
VariableDescriptionDefault
--radius-smSmall radius.25rem
--radius-mdMedium radius.5rem
--radius-lgLarge radius1rem
--radius-fullFull radius999px