Base Styles
Foundation styles that provide a consistent baseline for your application. Includes CSS reset, normalize styles, element defaults, and design tokens.
Overview
Apex's base styles provide a solid foundation for your application. They include:
- CSS Reset - Removes default browser styling for consistent cross-browser behavior
- Normalize Styles - Makes browsers render all elements more consistently
- Base Element Styles - Default styling for common HTML elements
- Design Tokens - CSS custom properties for colors, spacing, typography, and more
CSS Reset
The CSS reset removes default margins, padding, and borders from elements to provide a clean slate for styling.
Box Sizing
*,
*::before,
*::after {
box-sizing: border-box;
}Reset Elements
The following elements have their margins and padding reset:
body,
h1, h2, h3, h4, h5, h6,
p, ul, ol, dl, dd,
figure, blockquote, pre, code {
margin: 0;
}
ul, ol {
padding: 0;
list-style: none;
}
fieldset {
border: 0;
margin: 0;
}
hr {
border: 0;
}Form Elements
button {
cursor: pointer;
border: none;
background: none;
font-family: inherit;
}
input,
textarea,
select,
button {
appearance: none;
}
input,
textarea,
select {
border-radius: 0;
}Scrollbar Styling
Custom scrollbar styles are applied for WebKit browsers and Firefox:
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #a1a1a1;
}
* {
scrollbar-width: thin;
scrollbar-color: #c1c1c1 #f1f1f1;
}Normalize Styles
Based on normalize.css, these styles ensure cross-browser consistency for HTML elements.
Document Defaults
html {
line-height: 1.15;
font-size: 16px;
scroll-behavior: smooth;
text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
}
body {
margin: 0;
}
main {
display: block;
}Text Elements
h1 {
font-size: 2em;
margin: 0.67em 0;
}
b, strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub { bottom: -0.25em; }
sup { top: -0.5em; }Form Elements
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
line-height: 1.15;
margin: 0;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
appearance: auto;
}Base Element Styles
Default styling applied to HTML elements for a polished look out of the box.
Body
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, 'Helvetica Neue', Arial, sans-serif;
line-height: 1.5;
color: #1f2937;
background-color: #fff;
text-rendering: optimizelegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}Headings
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 600;
line-height: 1.25;
color: #111827;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }Links
a {
color: #3b82f6;
text-decoration: none;
transition: color 150ms ease;
}
a:hover {
color: #1d4ed8;
text-decoration: underline;
}Images
img {
max-width: 100%;
height: auto;
vertical-align: middle;
}Lists
ul, ol {
margin-top: 0;
margin-bottom: 1rem;
padding-left: 2rem;
}
li {
margin-bottom: 0.25rem;
}
dl {
margin-top: 0;
margin-bottom: 1rem;
}
dt {
font-weight: 600;
}
dd {
margin-left: 0;
margin-bottom: 0.5rem;
}Blockquotes
blockquote {
margin: 0 0 1rem;
padding: 0.5rem 1rem;
border-left: 4px solid #e5e7eb;
background-color: #f9fafb;
color: #4b5563;
}
blockquote p:last-child {
margin-bottom: 0;
}Code
pre {
margin-top: 0;
margin-bottom: 1rem;
padding: 1rem;
background-color: #1f2937;
color: #f3f4f6;
border-radius: 0.5rem;
overflow-x: auto;
font-size: 0.875rem;
line-height: 1.5;
}
code {
font-size: 0.875em;
padding: 0.125rem 0.25rem;
background-color: #f3f4f6;
border-radius: 0.25rem;
color: #ef4444;
}
pre code {
padding: 0;
background-color: transparent;
color: inherit;
}Tables
table {
width: 100%;
margin-bottom: 1rem;
border-collapse: collapse;
border-spacing: 0;
}
th, td {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #e5e7eb;
}
thead th {
vertical-align: bottom;
border-bottom: 2px solid #e5e7eb;
font-weight: 600;
text-align: left;
}
tbody + tbody {
border-top: 2px solid #e5e7eb;
}Form Inputs
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
display: block;
width: 100%;
padding: 0.5rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
color: #1f2937;
background-color: #fff;
border: 1px solid #d1d5db;
border-radius: 0.375rem;
transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:focus,
textarea:focus,
select:focus {
border-color: #3b82f6;
outline: none;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
input::placeholder,
textarea::placeholder {
color: #9ca3af;
}
input:disabled,
input[readonly],
textarea:disabled,
textarea[readonly],
select:disabled {
background-color: #f3f4f6;
cursor: not-allowed;
}Focus Visible
:focus-visible {
outline: 2px solid #3b82f6;
outline-offset: 2px;
}Design Tokens
CSS custom properties that define the design system. These can be customized at runtime for theming.
Colors
| Token | Value |
|---|---|
--color-primary | #3b82f6 |
--color-secondary | #64748b |
--color-success | #22c55e |
--color-danger | #ef4444 |
--color-warning | #f59e0b |
--color-info | #0ea5e9 |
--color-light | #f3f4f6 |
--color-dark | #1f2937 |
--color-white | #ffffff |
--color-black | #000000 |
--color-gray-50 | #f9fafb |
--color-gray-100 | #f3f4f6 |
--color-gray-200 | #e5e7eb |
--color-gray-300 | #d1d5db |
--color-gray-400 | #9ca3af |
--color-gray-500 | #6b7280 |
--color-gray-600 | #4b5563 |
--color-gray-700 | #374151 |
--color-gray-800 | #1f2937 |
--color-gray-900 | #111827 |
--color-gray-950 | #030712 |
--color-primary-50 | #eff6ff |
--color-primary-100 | #dbeafe |
--color-primary-200 | #bfdbfe |
--color-primary-300 | #93c5fd |
--color-primary-400 | #60a5fa |
--color-primary-500 | #3b82f6 |
--color-primary-600 | #2563eb |
--color-primary-700 | #1d4ed8 |
--color-primary-800 | #1e40af |
--color-primary-900 | #1e3a8a |
--color-primary-950 | #172554 |
--color-success-50 | #f0fdf4 |
--color-success-100 | #dcfce7 |
--color-success-200 | #bbf7d0 |
--color-success-300 | #86efac |
--color-success-400 | #4ade80 |
--color-success-500 | #22c55e |
--color-success-600 | #16a34a |
--color-success-700 | #15803d |
--color-success-800 | #166534 |
--color-success-900 | #14532d |
--color-success-950 | #052e16 |
--color-danger-50 | #fef2f2 |
--color-danger-100 | #fee2e2 |
--color-danger-200 | #fecaca |
--color-danger-300 | #fca5a5 |
--color-danger-400 | #f87171 |
--color-danger-500 | #ef4444 |
--color-danger-600 | #dc2626 |
--color-danger-700 | #b91c1c |
--color-danger-800 | #991b1b |
--color-danger-900 | #7f1d1d |
--color-danger-950 | #450a0a |
--color-warning-50 | #fffbeb |
--color-warning-100 | #fef3c7 |
--color-warning-200 | #fde68a |
--color-warning-300 | #fcd34d |
--color-warning-400 | #fbbf24 |
--color-warning-500 | #f59e0b |
--color-warning-600 | #d97706 |
--color-warning-700 | #b45309 |
--color-warning-800 | #92400e |
--color-warning-900 | #78350f |
--color-warning-950 | #451a03 |
--color-info-50 | #f0f9ff |
--color-info-100 | #e0f2fe |
--color-info-200 | #bae6fd |
--color-info-300 | #7dd3fc |
--color-info-400 | #38bdf8 |
--color-info-500 | #0ea5e9 |
--color-info-600 | #0284c7 |
--color-info-700 | #0369a1 |
--color-info-800 | #075985 |
--color-info-900 | #0c4a6e |
--color-info-950 | #082f49 |
Spacing
| Token | Rem | Pixels |
|---|---|---|
--spacing-0 | 0 | 0px |
--spacing-1 | 0.25rem | 4px |
--spacing-2 | 0.5rem | 8px |
--spacing-3 | 0.75rem | 12px |
--spacing-4 | 1rem | 16px |
--spacing-5 | 1.25rem | 20px |
--spacing-6 | 1.5rem | 24px |
--spacing-8 | 2rem | 32px |
--spacing-10 | 2.5rem | 40px |
--spacing-12 | 3rem | 48px |
--spacing-16 | 4rem | 64px |
--spacing-20 | 5rem | 80px |
--spacing-24 | 6rem | 96px |
--spacing-28 | 7rem | 112px |
--spacing-32 | 8rem | 128px |
--spacing-36 | 9rem | 144px |
--spacing-40 | 10rem | 160px |
--spacing-44 | 11rem | 176px |
--spacing-48 | 12rem | 192px |
--spacing-52 | 13rem | 208px |
--spacing-56 | 14rem | 224px |
--spacing-60 | 15rem | 240px |
--spacing-64 | 16rem | 256px |
--spacing-72 | 18rem | 288px |
--spacing-80 | 20rem | 320px |
--spacing-96 | 24rem | 384px |
Typography
| Category | Token | Value |
|---|---|---|
| Font Sizes | --font-size-xs | 0.75rem (12px) |
--font-size-sm | 0.875rem (14px) | |
--font-size-base | 1rem (16px) | |
--font-size-lg | 1.125rem (18px) | |
--font-size-xl | 1.25rem (20px) | |
--font-size-2xl | 1.5rem (24px) | |
--font-size-3xl | 1.875rem (30px) | |
--font-size-4xl | 2.25rem (36px) | |
--font-size-5xl | 3rem (48px) | |
| Font Weights | --font-weight-normal | 400 |
--font-weight-medium | 500 | |
--font-weight-semibold | 600 | |
--font-weight-bold | 700 | |
| Line Heights | --line-height-tight | 1.25 |
--line-height-snug | 1.375 | |
--line-height-normal | 1.5 | |
--line-height-relaxed | 1.625 | |
--line-height-loose | 2 | |
| Letter Spacing | --letter-spacing-tighter | -0.05em |
--letter-spacing-tight | -0.025em | |
--letter-spacing-normal | 0 | |
--letter-spacing-wide | 0.025em | |
--letter-spacing-wider | 0.05em | |
--letter-spacing-widest | 0.1em |
Effects
| Category | Token | Value |
|---|---|---|
| Shadows | --shadow-sm | 0 1px 2px 0 rgba(0, 0, 0, 0.05) |
--shadow-base | 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) | |
--shadow-md | 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) | |
--shadow-lg | 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) | |
--shadow-xl | 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) | |
--shadow-2xl | 0 25px 50px -12px rgba(0, 0, 0, 0.25) | |
--shadow-none | none | |
| Border Radius | --border-radius-none | 0 |
--border-radius-sm | 0.125rem (2px) | |
--border-radius-base | 0.25rem (4px) | |
--border-radius-md | 0.375rem (6px) | |
--border-radius-lg | 0.5rem (8px) | |
--border-radius-xl | 0.75rem (12px) | |
--border-radius-2xl | 1rem (16px) | |
--border-radius-full | 9999px | |
| Opacity | --opacity-0 | 0 |
--opacity-25 | 0.25 | |
--opacity-50 | 0.5 | |
--opacity-75 | 0.75 | |
--opacity-100 | 1 | |
| Transition Duration | --transition-duration-75 | 75ms |
--transition-duration-100 | 100ms | |
--transition-duration-150 | 150ms | |
--transition-duration-200 | 200ms | |
--transition-duration-300 | 300ms | |
| Transition Timing | --transition-timing-linear | linear |
--transition-timing-ease | ease | |
--transition-timing-ease-in | ease-in | |
--transition-timing-ease-out | ease-out | |
--transition-timing-ease-in-out | ease-in-out | |
--transition-timing-default | cubic-bezier(0.4, 0, 0.2, 1) | |
| Z-Index | --z-index-0 | 0 |
--z-index-10 | 10 | |
--z-index-20 | 20 | |
--z-index-30 | 30 | |
--z-index-40 | 40 | |
--z-index-50 | 50 | |
--z-index-auto | auto | |
--z-index-dropdown | 1000 |
Using Design Tokens
Design tokens can be used directly in your CSS or inline styles:
/* In your CSS */
.my-component {
color: var(--color-primary);
padding: var(--spacing-4);
font-size: var(--font-size-lg);
box-shadow: var(--shadow-md);
border-radius: var(--border-radius-lg);
}<!-- Inline styles -->
<div style="color: var(--color-primary); padding: var(--spacing-4);">
Styled with design tokens
</div>Dark Mode Support
All base styles automatically adapt to dark mode when enabled. Styles respond to both:
- prefers-color-scheme: dark media query (system preference)
- [data-theme="dark"] attribute (manual toggle)
Elements like body, headings, links, tables, forms, and code blocks automatically adjust their colors for dark mode.
Importing Base Styles
To use the base styles in your project, import the base index file:
// Import all base styles
@use 'apex/base' as base;Or import individual modules:
// Import specific modules
@use 'apex/base/colors' as colors;
@use 'apex/base/spacing' as spacing;
@use 'apex/base/typography' as typography;