Tailwind CSS

Source Design System

Foundation

Colours, spacing, radii and typography for capable design systems

Get started

Install packages

npm i -D source-foundation-cli
npm i -D source-tailwindcss

Learn more about Source Foundation CLI →

Create source.config.json

npx source-css init

Run the command above to create your ./source.config.json. This file has the parameters to generate colour palettes, typography, radii and spacing tokens.

Learn more about source.config.json →

Create CSS variables

npx source-css ./css/variables.css

The command above will read your ./source.config.json and create the CSS file ./css/variables.css.

See default CSS variables →

Import CSS variables

main.css
@import "./css/variables.css";
...
@tailwind base;
@tailwind components;
@tailwind utilities;

Configure TailwindCSS

Option 1. Import preset

tailwind.config.js
module.exports = {
    theme: { ... },
    ...
    presets: [
        require('source-tailwindcss')
    ]
}

Import a single Source Preset to enable all the features in the most simple way

Learn more about Tailwind CSS presets →

Option 2. Use theme

tailwind.config.js
module.exports = {
    theme: require('source-tailwindcss/source-theme'),
    plugins: [
        require('source-tailwindcss/plugins/border'),
        require('source-tailwindcss/plugins/colors'),
        require('source-tailwindcss/plugins/components'),
        require('source-tailwindcss/plugins/elevation'),
        require('source-tailwindcss/plugins/gradients'),
        require('source-tailwindcss/plugins/icons'),
        require('source-tailwindcss/plugins/padding')
    ]
}

Theme gives you more control over plugins.

Learn more about Tailwind CSS themes →

Set up HTML

index.html
<html data-theme="light" data-radii="base" data-spacing="base" data-typography="base" data-icons="base">
    ...
</html>

All the values are set with [data] atribute that you can apply to any element in your app.

[data] attribute variants
theme
light
dark-elevated
dark-base
spacing
compact
base
large
typography
compact
base
large
radii
compact
base
large
icons
base
touch

Now you shuld be able to run your build normally

Colour System

Colour system delivers seamless dark mode using CSS custom properties (a.k.a. variables). Source Design System completely replaces Tailwind colours with Source colours. It uses plugins to support CSS variables integration with Tailwind utility classes.

Learn more about Source Colour System →

Neutrals

Neutral colours are the foundation for the visual language that defines the overall tone of your application. It could be fully desaturated, slightly colder or warmer, or even tinted in a fancy way to support the brand.

Fills

Fills are the lightest shades in your arsenal and should be used as the main background colours.

Light surface colours
<div class="bg-fill-base-{shade} ..." />
100
200
300
400
500
600
Dark surface colours
<div class="bg-fill-contrast-{shade} ..." />
100
200
300
400
500
600

Strokes

Strokes are not supposed to fill large areas but outline or divide them.

Light surface strokes
<div class="border-stroke-base-{shade} ..." />
100
200
300
400
500
600
Dark surface strokes
<div class="border-stroke-contrast-{shade} ..." />
100
200
300
400
500
600

Alt Colours

Alt or alternative colours are semi-transparent ones and could be applied both as fills and strokes.

Light surface tints
<div class="bg-alt-base-{shade} ..." />
100
200
300
400
500
600
Dark surface tints
<div class="bg-alt-contrast-{shade} ..." />
100
200
300
400
500
600

Primary / Brand Colour

Brand colour is key to the immediate brand recognition of your product

<div class="bg-primary-{shade} ..." />
100
200
300
400
500
600

Semantics

These colours communicate feedback, status, or urgency and should always convey important information

Success

<div class="bg-success-{shade} ..." />
100
200
300
400
500
600

Info

<div class="bg-info-{shade} ..." />
100
200
300
400
500
600

Warning

<div class="bg-warning-{shade} ..." />
100
200
300
400
500
600

Danger

<div class="bg-danger-{shade} ..." />
100
200
300
400
500
600

Text colours

<span class="color-{color} ..." />

For the text, there are three shades for visual hierarchy and several colours for semantics. It is an independent sub-palette that makes it easier to fit into WCAG accessibility requirements.

Semantics are derived from accents. Shade 500 is for light backgrounds and shade 600 is for dark backgrounds.

Text on light background

--text-base-600
--text-base-500
--text-base-400
--text-base-action
--text-base-info
--text-base-success
--text-base-warning
--text-base-danger

Text on dark background

--text-contrast-600
--text-contrast-500
--text-contrast-400
--text-contrast-action
--text-contrast-info
--text-contrast-success
--text-contrast-warning
--text-contrast-danger

Accents

The accent palette brings life and meaning to your product. The colour spots can guide user attention, emphasise brand connection or communicate a system state. There are ten accents to work with.

<div class='bg-accent-red-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-amber-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-brown-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-green-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-teal-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-blue-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-indigo-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-violet-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-purple-{shade} ...' />
100
200
300
400
500
600
<div class='bg-accent-pink-{shade} ...' />
100
200
300
400
500
600

Colour Adjustments

Colour opacity

Colour opacity is adjusted with color-mix() function

<div class="bg-opacity-{opacity} border-opacity-{opacity} color-opacity-{opacity} ..." />
.bg-opacity-90 {
    background-color: color-mix(in srgb, var(--bg-color), transparent 10%);
}
.border-opacity-90 {
    border-color: color-mix(in srgb, var(--border-color), transparent 10%);
}
.color-opacity-90 {
    color: color-mix(in srgb, var(--text-color), transparent 10%);
}
bg-opacity-90
bg-opacity-80
bg-opacity-70
bg-opacity-60
bg-opacity-50
color-opacity-90
color-opacity-80
color-opacity-70
color-opacity-60
color-opacity-50

Colour tint

Colour tint adds a linear gradient with two semitransparent white colour stops.

<div class="tint-{opacity} ..." />
.tint-30 {
    background-image: linear-gradient(180deg, hsla(0deg 0% 100% / 30%), hsla(0deg 0% 100% / 30%));
}
tint-10
tint-20
tint-30
tint-40
tint-50

Background Blend Mode

<div class="tint-{opacity} bg-blend-overlay ..." />
tint-10
tint-20
tint-30
tint-40
tint-50

Colour shade

Colour shade adds a linear gradient with two semitransparent black colour stops.

<div class="shade-{opacity} ..." />
.shade-30 {
    background-image: linear-gradient(180deg, hsla(0deg 0% 0% / 30%), hsla(0deg 0% 0% / 30%));
}
shade-10
shade-20
shade-30
shade-40
shade-50

Background Blend Mode

<div class="shade-{opacity} bg-blend-overlay ..." />
shade-10
shade-20
shade-30
shade-40
shade-50

Gradients

Gradient Tint

<div class="gradient-tint-{opacity} gradient-angle-{angle} ..." />

Tint gradient makes a gradient on top of any colour using background-blend-mode: overlay By default it creates tint on top of the surface, you can change gradient angle with gradient-angle

Examples below demonstrate gradient-tint-50 on top of different accents

gradient-angle-180
gradient-angle-135
gradient-angle-90
gradient-angle-45
gradient-angle-0

Gradient Shade

<div class="gradient-shade-{opacity} gradient-angle-{angle} ..." />

There is another utility that shades part of the surface. Examples below demonstrate gradient-shade-50 on top of different accents.

gradient-angle-0
gradient-angle-45
gradient-angle-90
gradient-angle-135
gradient-angle-180

Gradient Mix

<div class="gradient-mix-{color} gradient-angle-{angle} ..." />

This utility makes a gradient using specific colour. Examples below demonstrate the mix of two accents.

gradient-angle-0
gradient-angle-45
gradient-angle-90
gradient-angle-135
gradient-angle-180

Also you can use them with icons

<span class="icon icon-{icon} color-{color} gradient-mix-{color} gradient-angle ..." />

Shadows

Drop Shadows

<div class="shadow-{elevation} shadow-{color} shadow-opacity-{opacity} ..." />

Shadow utility offers six elevation levels. examples below use shadow-utility-shade-300 colour.

shadow-1
shadow-2
shadow-3
shadow-4
shadow-5
shadow-6

Shadow colour

By default shadows use special colour utility-shade-{100...600}

shadow-utility-shade-100
shadow-utility-shade-200
shadow-utility-shade-300
shadow-utility-shade-400
shadow-utility-shade-500
shadow-utility-shade-600

Color Bleed Shadows

You can apply any colour with shadow-{color} and set shadow opacity with shadow-opacity-{opacity} utilities.

shadow-accent-green-300
shadow-opacity-60
shadow-accent-teal-300
shadow-opacity-60
shadow-accent-blue-300
shadow-opacity-60
shadow-accent-indigo-300
shadow-opacity-60

Multiply Shadows

Utility class shadow-multiply enables mix-blend-mode: multiply on shadows. Switch theme to see the difference.

shadow-accent-green-300
shadow-opacity-60
shadow-accent-teal-300
shadow-opacity-60
shadow-accent-blue-300
shadow-opacity-60
shadow-accent-indigo-300
shadow-opacity-60

Inner Shadows

<div class="inner-shadow-{elevation} inner-shadow-{color} inner-shadow-opacity-{opacity} ..." />
inner-shadow-1
inner-shadow-2
inner-shadow-3
inner-shadow-4

Combine Drop & Inner Shadows

Special utility class shadows combines both drop and inner shadows

<div class="shadows shadow-{elevation} inner-shadow-{elevation} ..." />
inner-shadow-2 shadow-3
inner-shadow-2 shadow-2
inner-shadow-4 shadow-4

Spacing

Primary spacing scale. Use for evenly spaced containers or pair with minor value for optically balanced results

--spacing-xs4

--spacing-xs3

--spacing-xs2

--spacing-xs

--spacing-sm

--spacing-base

--spacing-md

--spacing-lg

--spacing-xl

--spacing-xl2

--spacing-xl3

--spacing-xl4

--spacing-xl5
Additional spacing scale. Use for vertical spacing and pair with primary value for optically balanced results

--spacing-minor-xs4

--spacing-minor-xs3

--spacing-minor-xs2

--spacing-minor-xs

--spacing-minor-sm

--spacing-minor-base

--spacing-minor-md

--spacing-minor-lg

--spacing-minor-xl

--spacing-minor-xl2

--spacing-minor-xl3

--spacing-minor-xl4

--spacing-minor-xl5

Typography

--font-size-xs2 / --line-height-xs2
Quick brown fox jumps over the lazy dog

--font-size-xs / --line-height-xs
Quick brown fox jumps over the lazy dog

--font-size-sm / --line-height-sm
Quick brown fox jumps over the lazy dog

--font-size-base / --line-height-base
Quick brown fox jumps over the lazy dog

--font-size-md / --line-height-md
Quick brown fox jumps over the lazy dog

--font-size-lg / --line-height-lg
Quick brown fox jumps over the lazy dog

--font-size-xl / --line-height-xl
Quick brown fox jumps over the lazy dog

--font-size-xl2 / --line-height-xl2
Quick brown fox jumps over the lazy dog

--font-size-xl3 / --line-height-xl3
Quick brown fox jumps over the lazy dog

--font-size-xl4 / --line-height-xl4
Quick brown fox jumps over the lazy dog

--font-size-xl5 / --line-height-xl5
Quick brown fox jumps over the lazy dog

--font-size-xl6 / --line-height-xl6
Quick brown fox jumps over the lazy dog

--font-size-xl7 / --line-height-xl7
Quick brown fox jumps over the lazy dog

Radii

--radii-none
--radii-sm
--radii-base
--radii-md
--radii-lg
--radii-xl
--radii-xl2
--radii-round

Icons

Icon set is based on Feather Icons, popular and well recognised style. It was refined for lower DPI screens and extended with filled variant

<span class="icon icon-{name} icon-{size} ..." />

Sizes

--icon-size-sm
--icon-size-base
--icon-size-md
--icon-size-lg
--icon-size-xl
--icon-size-xl2
--icon-size-xl3
--icon-size-xl4
--icon-size-xl5

Names

<span class="icon icon-md icon-{name} ..." />
activity
airplay
alert-circle
alert-circle-filled
alert-octagon
alert-octagon-filled
alert-triangle
alert-triangle-filled
align-center
align-justify
align-left
align-right
anchor
aperture
aperture-filled
appearance
archive
archive-filled
arrow-down
arrow-down-circle
arrow-down-circle-filled
arrow-down-left
arrow-down-right
arrow-left
arrow-left-circle
arrow-left-circle-filled
arrow-left-right
arrow-right
arrow-right-circle
arrow-right-circle-filled
arrow-up
arrow-up-circle
arrow-up-circle-filled
arrow-up-down
arrow-up-left
arrow-up-right
at-sign
award
award-filled
bar-chart
bar-chart-2
bar-chart-2-filled
bar-chart-filled
battery
battery-100
battery-33
battery-50
battery-charging
bell
bell-filled
bell-off
bell-off-filled
bluetooth
bold
book
book-filled
book-open
book-open-filled
bookmark
bookmark-filled
box
box-filled
box-wire
briefcase
briefcase-filled
calendar
calendar-filled
camera
camera-filled
camera-off
camera-off-filled
caret-down
caret-down-filled
caret-up
caret-up-filled
cast
cast-filled
check
check-circle
check-circle-filled
check-filled
check-square
check-square-filled
check-stamp
check-stamp-filled
chevron-down
chevron-left
chevron-right
chevron-up
chevrons-down
chevrons-left
chevrons-right
chevrons-up
chrome
chrome-filled
circle
circle-filled
clipboard
clipboard-filled
clock
clock-filled
cloud
cloud-drizzle
cloud-filled
cloud-lightning
cloud-off
cloud-off-filled
cloud-rain
cloud-snow
code
codepen
coffee
coffee-filled
columns
columns-filled
command
compass
compass-filled
copy
copy-filled
corner-down-left
corner-down-right
corner-left-down
corner-left-up
corner-right-down
corner-right-up
corner-up-left
corner-up-right
cpu
cpu-filled
credit-card
credit-card-filled
credit-card-plus
crop
crosshair
crosshair-filled
cup
cup-filled
database
database
database
database-filled
database-filled
database-filled
delete
delete-filled
disc
disc-filled
dollar-sign
dot
dot-filled
download
download-cloud
droplet
droplet-filled
edit
edit-2
edit-2-filled
edit-3
edit-3-filled
external-link
eye
eye-filled
eye-off
eye-off-filled
facebook
facebook-filled
fast-forward
fast-forward-filled
feather
feather-filled
file
file-filled
file-minus
file-plus
file-plus-circle
file-plus-circle-filled
file-plus-filled
file-text
file-text-filled
film
film-filled
filter
filter-filled
filter-x
filter-x-filled
fire
fire-filled
flag
flag-filled
folder
folder-filled
folder-minus
folder-minus-filled
folder-plus
folder-plus-filled
frown
frown-filled
gift
gift-filled
git-branch
git-commit
git-merge
git-pull-request
github
gitlab
gitlab-filled
globe
globe-filled
grid
grid-filled
hard-drive
hard-drive-filled
hash
headphones
headphones-filled
heart
heart-filled
help-circle
help-circle-filled
home
home-filled
image
image-filled
image-plus
image-plus-circle
image-plus-circle-filled
image-plus-filled
inbox
inbox-filled
info
info-filled
instagram
instagram-filled
italic
key
key-filled
layers
layers-filled
layout
layout-filled
life-buoy
life-buoy-filled
link
link-2
linkedin
linkedin-filled
list
list-ordered
lock
lock-filled
log-in
log-out
mail
mail-filled
mail-open
mail-open-filled
maintenance
maintenance-filled
map
map-filled
map-pin
map-pin-filled
maximize
maximize-2
meh
meh-filled
menu
message-circle
message-circle-filled
message-square
message-square-filled
mic
mic-filled
mic-off
mic-off-filled
minimize
minimize-2
minus
minus-circle
minus-circle-filled
minus-square
minus-square-filled
monitor
monitor-filled
moon
moon-filled
more-cirle
more-cirle-filled
more-horizontal
more-vertical
mouse-pointer
mouse-pointer-filled
move
music
music-filled
navigation
navigation-2
navigation-2-filled
navigation-filled
octagon
octagon
octagon
octagon-filled
octagon-filled
octagon-filled
package
package-filled
paperclip
pause
pause-circle
pause-circle-filled
pause-filled
pen-tool
pen-tool-filled
percent
phone
phone-call
phone-call-filled
phone-filled
phone-forwarded
phone-forwarded-filled
phone-incoming
phone-incoming-filled
phone-missed
phone-missed-filled
phone-off
phone-off-filled
phone-outgoing
phone-outgoing-filled
pie-chart
pie-chart-filled
pinterest
pinterest-filled
play
play-circle
play-circle-filled
play-filled
plus
plus-circle
plus-circle-filled
plus-filled
plus-square
plus-square-filled
pocket
pocket-filled
power
printer
printer-filled
quote
quote-filled
radio
refresh-ccw
refresh-cw
repeat
rewind
rewind-filled
rotate-ccw
rotate-cw
rows
rows-filled
rss
rss-filled
save
save-filled
scan
scan-filled
scissors
screwdriver
screwdriver-filled
search
send
send-filled
server
server-filled
settings
settings-filled
share
share-2
share-2-filled
shield
shield-filled
shield-off
shield-off-filled
shopping-bag
shopping-bag-filled
shopping-cart
shopping-cart-filled
shuffle
shuffle-filled
sidebar
sidebar-filled
skip-back
skip-back-filled
skip-forward
skip-forward-filled
slack
slack-filled
slash
sliders
sliders-filled
smartphone
smartphone-filled
smile
smile-filled
source-ds
speaker
speaker-filled
square
square-filled
star
star-filled
star-half
star-half-filled
stop-circle
stop-circle-filled
strike
sun
sun-filled
sunrise
sunrise-filled
sunset
sunset-filled
table
table-filled
tablet
tablet-filled
tag
tag-filled
target
target-filled
terminal
thermometer
thermometer-filled
thumbs-down
thumbs-down-filled
thumbs-up
thumbs-up-filled
toggle-left
toggle-left-filled
toggle-right
toggle-right-filled
trash-2
trash-2-filled
trello
trello-filled
trending-down
trending-down-square
trending-down-square-filled
trending-up
trending-up-square
trending-up-square-filled
triangle
triangle-filled
truck
truck-filled
tv
tv-filled
twitter
twitter-filled
type
umbrella
umbrella-filled
underline
underline
underline
unlock
unlock-filled
upload
upload-cloud
user
user-check
user-check-filled
user-circle
user-circle-filled
user-filled
user-plus
user-plus-filled
user-x
user-x-filled
users
users-filled
video
video-filled
video-off
video-off-filled
voicemail
volume
volume-1
volume-1-filled
volume-2
volume-2-filled
volume-filled
volume-x
volume-x-filled
wallet
wallet-filled
wallet-receive
wallet-receive-filled
wallet-send
wallet-send-filled
watch
watch-filled
wifi
wifi-2
wifi-off
wind
wrench
wrench-filled
x
x-circle
x-circle-filled
x-square
x-square-filled
youtube
youtube-filled
zap
zap-filled
zap-off
zap-off-filled
zoom-in
zoom-in-filled
zoom-out
zoom-out-filled