Overview:
Blueprint Styler is a tool that allows users to create custom global styles for Blueprint.js components using CSS custom properties, also known as “Tokens”. By overriding the default Blueprint global CSS, users can have more control over the styling of the components. There are two ways to create a custom theme: integrating Blueprint Styler into an existing project or creating a new theme within the Blueprint Styler project itself.
Features:
- Custom Global Styles: Override or replace the default Blueprint global CSS with custom styles.
- CSS Custom Properties: Use CSS custom properties (Tokens) to define and manage the styling of Blueprint.js components.
- Integration with Existing Project: Easily install Blueprint Styler into an existing project and import the necessary styles.
- Demo React App: Develop and test themes in the demo React app provided with Blueprint Styler.
- Theme Manifest: Add new themes to the style manifest file for easy reference and selection.
- Style Overrides: Copy and paste existing styles from Blueprint Styler’s library and modify them to create custom styles.
- Utility SCSS Files: Access utility SCSS files in the global folder for additional styling options.
Installation:
Theme Blueprint In Your Project:
- Install Blueprint Styler in your project by running either of the following commands:
npm install blueprint-styleryarn add blueprint-styler
- Import the blueprint base styles from
./base/blueprint.cssand./base/blueprint-tokens.css. - Optionally, import an existing style override to start from, located at
./overrides/{style_name}/override.cssand./overrides/{style_name}/override-tokens.css. - In your CSS file, add a
:rootselector and override the--custom-propertiesfromblueprint-tokens.css. - If needed, override global CSS in
blueprint.cssfor additional control.
Create A Blueprint Theme In This Project:
- Create a new
_examplefolder in./src/styles. - The
_examplefolder must contain:- A root SCSS file named
index.scss, which will compile into theoverrides/example/override.cssandoverrides/example/override-tokens.cssfiles. This file must also set the$ns(namespace) and!default $root-selectorvariables. - A secondary root file named
styler-styles.scssthat extendsindex.scssto style the demo React app components. This file must reset the$root-selectorto scope the style to an app’s theme switching method.
- A root SCSS file named
- Add your theme to the
src/styles/style-manifest.tsfile, following the pattern of other themes. - Ensure that everything exported is wrapped in a
#{$root-selector} {...}block to scope it accordingly. - Copy and paste variables and styles from files in
./src/styles/_blueprint/common/and./src/styles/_blueprint/components/, and change the values to override them. - Test your theme by running the demo app with
yarn start, accessinghttp://localhost:9000/, and selecting the theme from the style dropdown.
Summary:
Blueprint Styler is a versatile tool that allows users to create custom global styles for Blueprint.js components. By utilizing CSS custom properties and overrides, users can have full control over the styling of these components. With the option to integrate into an existing project or create a new theme within the Blueprint Styler project, users have flexibility in how they implement and test their custom styling. The provided demo app and utility SCSS files further enhance the customization capabilities of Blueprint Styler.