Skip to main content

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

CSS
*,
*::before,
*::after {
  box-sizing: border-box;
}

Reset Elements

The following elements have their margins and padding reset:

CSS
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

CSS
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:

CSS
::-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

CSS
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

CSS
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

CSS
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

CSS
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

CSS
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

CSS
a {
  color: #3b82f6;
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

Images

CSS
img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

Lists

CSS
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

CSS
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

CSS
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

CSS
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

CSS
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

CSS
: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

TokenValue
--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

TokenRemPixels
--spacing-000px
--spacing-10.25rem4px
--spacing-20.5rem8px
--spacing-30.75rem12px
--spacing-41rem16px
--spacing-51.25rem20px
--spacing-61.5rem24px
--spacing-82rem32px
--spacing-102.5rem40px
--spacing-123rem48px
--spacing-164rem64px
--spacing-205rem80px
--spacing-246rem96px
--spacing-287rem112px
--spacing-328rem128px
--spacing-369rem144px
--spacing-4010rem160px
--spacing-4411rem176px
--spacing-4812rem192px
--spacing-5213rem208px
--spacing-5614rem224px
--spacing-6015rem240px
--spacing-6416rem256px
--spacing-7218rem288px
--spacing-8020rem320px
--spacing-9624rem384px

Typography

CategoryTokenValue
Font Sizes--font-size-xs0.75rem (12px)
--font-size-sm0.875rem (14px)
--font-size-base1rem (16px)
--font-size-lg1.125rem (18px)
--font-size-xl1.25rem (20px)
--font-size-2xl1.5rem (24px)
--font-size-3xl1.875rem (30px)
--font-size-4xl2.25rem (36px)
--font-size-5xl3rem (48px)
Font Weights--font-weight-normal400
--font-weight-medium500
--font-weight-semibold600
--font-weight-bold700
Line Heights--line-height-tight1.25
--line-height-snug1.375
--line-height-normal1.5
--line-height-relaxed1.625
--line-height-loose2
Letter Spacing--letter-spacing-tighter-0.05em
--letter-spacing-tight-0.025em
--letter-spacing-normal0
--letter-spacing-wide0.025em
--letter-spacing-wider0.05em
--letter-spacing-widest0.1em

Effects

CategoryTokenValue
Shadows--shadow-sm0 1px 2px 0 rgba(0, 0, 0, 0.05)
--shadow-base0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)
--shadow-md0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)
--shadow-lg0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)
--shadow-xl0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)
--shadow-2xl0 25px 50px -12px rgba(0, 0, 0, 0.25)
--shadow-nonenone
Border Radius--border-radius-none0
--border-radius-sm0.125rem (2px)
--border-radius-base0.25rem (4px)
--border-radius-md0.375rem (6px)
--border-radius-lg0.5rem (8px)
--border-radius-xl0.75rem (12px)
--border-radius-2xl1rem (16px)
--border-radius-full9999px
Opacity--opacity-00
--opacity-250.25
--opacity-500.5
--opacity-750.75
--opacity-1001
Transition Duration--transition-duration-7575ms
--transition-duration-100100ms
--transition-duration-150150ms
--transition-duration-200200ms
--transition-duration-300300ms
Transition Timing--transition-timing-linearlinear
--transition-timing-easeease
--transition-timing-ease-inease-in
--transition-timing-ease-outease-out
--transition-timing-ease-in-outease-in-out
--transition-timing-defaultcubic-bezier(0.4, 0, 0.2, 1)
Z-Index--z-index-00
--z-index-1010
--z-index-2020
--z-index-3030
--z-index-4040
--z-index-5050
--z-index-autoauto
--z-index-dropdown1000

Using Design Tokens

Design tokens can be used directly in your CSS or inline styles:

CSS
/* 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);
}
HTML
<!-- 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:

SCSS
// Import all base styles
@use 'apex/base' as base;

Or import individual modules:

SCSS
// Import specific modules
@use 'apex/base/colors' as colors;
@use 'apex/base/spacing' as spacing;
@use 'apex/base/typography' as typography;