The SCSS/CSS file defines classes for elements commonly used when developing a custom element or an open source tool that seeks to maintain Kontent.ai visual identity, such as inputs, buttons, etc. It also comes with predefined color classes, using a palette from Kontent.ai application interface. The color classes can be combined with most of the element classes to streamline the styling process.
Install using your preferred package manager.
npm i @kontent-ai/stylekit
If your environment supports it (e.g. you're using a bundler), you can import the styles directly:
import '@kontent-ai/stylekit';
Alternatively, you can link the CSS from node_modules
:
<link rel="stylesheet" href="node_modules/@kontent-ai/stylekit/styles/styles.css">
There are twelve base colors defined in the CSS, wrapped in a matching number of color classes of the same name (minus the CSS custom property syntax --
). These are as follows:
You can combine the color classes with most of the elements in the following manner:
<div class="button red">Red button</div>
If you want to use any of the colors in your own class, use CSS var()
function, e.g. color: var(--red)
.
Note
Class names do not correspond to their CSS color counterparts. All colors are custom, matching the Kontent.ai application interface.
One-class-does-it-all styles with optional modifiers.
A round, color-filled button with a hover animation. Defaults to upper-case font, which can be overridden using no-caps
helper class.
secondary
: bordered button, sets background color towhite
, defaults font color toblack
destructive
: specific style for Delete and similar actions, matches UI[color-class-name]
: affectsborder-color
andbackground-color ::hovered
,background-color
for secondary onlyno-caps
: setstext-transform
tonone
disabled
: setsopacity
to 0.5 and disables pointer events
<div class="button destructive">Delete</div>
<div class="button green">Save</div>
<div class="button secondary">Cancel</div>
Tip
Buttons follow their UI hierarchy. Default (primary) button is filled, secondary button is bordered.
destructive
is a standalone style and shouldn't be combined with secondary
modifier.
Base class for all kinds of inputs, comes in a form of rounded box with hover effect.
[color-class-name]
: affectsborder-color
and its:hover
statetype="text"
: sets placeholder color to light-grey and cursor totext
disabled
: setsopacity
to 0.5 and disables pointer events
<input class="input" placeholder="Insert something" type="text">
A small pill-shaped informative element with optional colored background. Useful e.g. for displaying a loading status of an asynchronously fetched asset.
[color-class-name]
: affectsborder-color
,background-color
and sets fontcolor
towhite
<div class="status red">Loading failed.</div>
A bordered area for content, with round corners and predefined padding, suitable for separating UI elements.
[color-class-name]
: affectsborder-color
<div class="section">
<div>Some text content</div>
<div class="button">Button</div>
</div>
Same as section but with background color set to 10% of border color. Suitable for warning or info boxes.
[color-class-name]
: affectsborder-color
,background-color
<div class="section info red">
<h2>Warning</h2>
<p>Some warning message.</p>
</div>
A simple animation to display if the custom element is busy loading a resource, e.g. from an asynchronous operation.
Apply dynamically and combine with pointer-events: none
to prevent user interaction.
<div class="loader"></div>
[color-class-name]
: affects the loader colors
Multiple classes meant to be used together to achieve the desired style.
Modified checkbox in form of an animated on/off switch.
.switch
,.slider
slider [color-class-name]
: affects color of a toggled switchdisabled
: setsopacity
to 0.5 and disables pointer events
<label class="switch">
Switch
<input type="checkbox" id="switch">
<span class="slider red"></span>
</label>
Animated checkbox in UI colors.
.checkbox
,.checkmark
disabled
: setsopacity
to 0.5 and disables pointer events
<label class="checkbox">
<input type="checkbox" id="checkbox">
<span class="checkmark"></span>
Expert
</label>
Animated radio buttons in UI colors.
.radio
,.radio-button
disabled
: setsopacity
to 0.5 and disables pointer events
<label class="radio">
<input type="radio" name="radio" checked>
<span class="radio-button"></span>
Option 1
</label>
<label class="radio">
<input type="radio" name="radio">
<span class="radio-button"></span>
Option 2
</label>
Input in form of an animated dropdown menu with multiple options.
.select
,.options
,.option
.option.selected
: highlights the currently selected option in the dropdown.select.open
: when theopen
class is set, it applies animated 180 degree rotation to the arrow. Rotates back when the class is removed.disabled
: setsopacity
to 0.5 and disables pointer events
<div class="select">Pick an option</div>
<div class="options">
<div class="option">Available option</div>
<div class="option selected">Selected option</div>
</div>
Note
Above example doesn't work on its own but expects JavaScript to handle toggle and selection events.
It's possible to use the select
class with the HTML <select>
element by removing its default styling and applying the class on a wrapper div.
Clone the repository and adjust the styles.scss file accordingly. To test the styles locally, run npm run convert
to build the styles.css file and its map.