Modular
This guide covers how to trim your CSS and JS bundles by importing only what you use from bestax-bulma and Bulma.
For most projects, import the combined bundle and let React handle the rest:
import '@allxsmith/bestax-bulma/bestax.css';
bestax.css is already minified and small, and modern bundlers tree-shake unused components from the JS side automatically. You only need to go modular if you've measured CSS size and have a specific constraint to hit.
Modular optimization has two independent axes:
- JS bundle — handled by your bundler's tree shaking. Just use named imports.
- CSS bundle — handled by choosing one of the CSS options below (combined, extras-only, or hand-rolled SCSS).
JS: named imports and tree shaking
bestax-bulma is published as ES modules, one file per source module, with "sideEffects": ["**/*.css", "**/*.scss"] in its package.json. That means Vite, Webpack 5, Rollup, esbuild, Next.js, and other modern bundlers strip out any component you don't reference — no extra configuration required.
// Good — only the components you name are bundled
import { Button, Box, Card } from '@allxsmith/bestax-bulma';
Component categories
Components are organized by Bulma category. Import from the same package path regardless of category:
import { Button, Icon, Title } from '@allxsmith/bestax-bulma'; // Elements
import { Card, Modal, Navbar } from '@allxsmith/bestax-bulma'; // Components
import { Input, Select, Checkbox } from '@allxsmith/bestax-bulma'; // Form
import { Container, Hero, Section } from '@allxsmith/bestax-bulma'; // Layout
import { Columns, Column } from '@allxsmith/bestax-bulma'; // Columns
import { Grid, Cell } from '@allxsmith/bestax-bulma'; // Grid
import {
ConfigProvider,
Theme,
useBulmaClasses,
} from '@allxsmith/bestax-bulma'; // Helpers
The categories above are illustrative, not exhaustive. See the Elements, Components, Form, Layout, Columns, and Grid API sections for the complete list, including newer additions like Dialog, Carousel, Tooltip, Steps, Sidebar, Toast, Loading, Collapse, Autocomplete, Taginput, Rate, Slider, NumberInput, Switch, Checkboxes, and Radios.
CSS: the ways to load styles
Option A — combined bundle (recommended)
One import gives you Bulma and all bestax extras:
import '@allxsmith/bestax-bulma/bestax.css';
bestax.css is already minified. After gzip/Brotli, the difference between it and a hand-tuned modular build is usually a few KB — not worth the ongoing maintenance of keeping SCSS imports in sync as you add components. Start here, then measure before optimizing further.
Option B — Bulma + extras separately
If you're already managing Bulma's CSS yourself (e.g. using a specific variant, CDN, or custom theme build), add only the bestax extras on top:
import 'bulma/css/bulma.min.css';
import '@allxsmith/bestax-bulma/extras.css';
extras.css contains only the styles for components bestax adds on top of Bulma (Dialog, Carousel, Tooltip, Autocomplete, etc.).
Option C — hand-rolled modular SCSS (advanced)
Hand-rolling modular SCSS is worthwhile only when you have a demonstrated CSS-size budget. You take on the maintenance burden of keeping imports in sync with the components you actually use. If in doubt, use Option A.
Install Bulma, whose partials you @use below, and Sass as a dev dependency. bestax-bulma depends on Bulma, but under pnpm's default layout your Sass can only load the packages your app lists:
- pnpm
- npm
- yarn
- bun
pnpm add bulma
pnpm add -D sass
npm install bulma
npm install -D sass
yarn add bulma
yarn add -D sass
bun add bulma
bun add -d sass
If pnpm stops on a build script here, see When pnpm blocks a build script.
Required base styles
Before importing component partials, include Bulma's base (CSS reset, generic element styles, keyframes) and themes (CSS custom properties on :root):
// Required: reset + CSS variable definitions
@use 'bulma/sass/base';
@use 'bulma/sass/themes';
baseprovidesminireset, generic element styles, and animation keyframes.themesregisters the--bulma-*CSS custom properties (colors, radii,--bulma-scheme-main, etc.) and sets up light/dark mode.
bulma/sass/grid/columns and bulma/sass/grid/grid register their own CSS variables internally and compile their breakpoints from SCSS, so they can technically be used without base and themes. The safe default is still to include both — you'll almost always want them as soon as you add a second component.
Bulma component partials
After the base, @use only the Bulma partials you need:
// Elements
@use 'bulma/sass/elements/button';
@use 'bulma/sass/elements/box';
@use 'bulma/sass/elements/notification';
@use 'bulma/sass/elements/title';
// Form
@use 'bulma/sass/form/input-textarea';
@use 'bulma/sass/form/select';
@use 'bulma/sass/form/tools';
// Components
@use 'bulma/sass/components/card';
@use 'bulma/sass/components/modal';
@use 'bulma/sass/components/navbar';
// Grid systems
@use 'bulma/sass/grid/columns';
@use 'bulma/sass/grid/grid';
// Layout
@use 'bulma/sass/layout/container';
@use 'bulma/sass/layout/section';
Bulma groups some form controls into one module: form/input-textarea styles both Input and TextArea, form/checkbox-radio styles Checkbox and Radio, and form/tools styles Field and Control.
bestax's prebuilt stylesheets build Bulma's table with $table-cell-text-align: start, so a table's header cells line up with the body cells under them on a right-to-left page too, where Bulma's default, left, keeps them on the left. A modular build with a Table or a DataTable gets the same by configuring the module where it loads it:
@use 'bulma/sass/elements/table' with (
$table-cell-text-align: start
);
A build with a responsive Table also wants bestax's elements/table partial, for its container's focus ring, and so does one with selected rows, in a Table or a DataTable, which the partial marks in forced colors.
A build with a Select also wants bestax's form/select partial, which outlines a focused select in forced colors and draws a disabled one's arrow in the disabled color there.
Pull in only the helper categories you use:
@use 'bulma/sass/helpers/spacing';
@use 'bulma/sass/helpers/color';
@use 'bulma/sass/helpers/typography';
@use 'bulma/sass/helpers/flexbox';
@use 'bulma/sass/helpers/other';
With bulma/sass/helpers/color, add bestax's helpers/color partial too. The next section says what it adjusts.
bestax extras partials
bestax ships SCSS partials for the components it adds on top of Bulma that need styles of their own, and for some of the stock Bulma components it adjusts. Load the ones your app uses the same way, through the package's scss/* export. The extras inventory in the bestax-optimize skill lists every partial by folder, and is checked against the partials the package ships.
For example, an app with a Dialog, a Tooltip and an Autocomplete, that also uses the Bulma button and navbar modules and the color helpers above:
@use '@allxsmith/bestax-bulma/scss/components/dialog';
@use '@allxsmith/bestax-bulma/scss/components/tooltip';
@use '@allxsmith/bestax-bulma/scss/form/autocomplete';
@use '@allxsmith/bestax-bulma/scss/elements/button' as bestax-button;
@use '@allxsmith/bestax-bulma/scss/components/navbar' as bestax-navbar;
@use '@allxsmith/bestax-bulma/scss/helpers/color' as bestax-color;
Some partials adjust a stock Bulma component rather than add one of bestax's.
-
elements/notificationkeeps aNotification's text clear of its close button, and gives a dark or light one its color's own text and background, and a white or black one withisLightthe light color's text, where Bulma's module lets its text inherit the color around it, so a build that usesbulma/sass/elements/notificationwants it too. -
elements/predraws aPre's keyboard focus ring, which is a tab stop while its content overflows, so a build that shows aPrewants it. Bulma draws the<pre>in its base, which every build has, so it needs no Bulma module of its own. -
elements/tabledraws the keyboard focus ring of a responsive table's container, which is a tab stop while the table overflows it, and marks a selected row or cell with a double line in forced colors, where Bulma's fill for it is replaced, so a build that usesbulma/sass/elements/tablefor aTablewithisResponsiveor selected rows, or for aDataTablethat selects rows, wants it too. -
elements/taggives a light tag, and a white, black or dark one withisLight, readable text, sets a normal-size tag in a table cell at the bottom of its line, where Bulma's baseline makes the row taller than a row of text, and gives a button tag (as="button",isDelete) the weight, spacing and other text a span tag takes from the text around it, where the browser gives a button its own, so a build that usesbulma/sass/elements/tagwants it too. -
components/modalkeeps a modal card's edge in forced colors (Windows' contrast themes), where Bulma's card has none and the backdrop's dark fill is replaced, so a build that usesbulma/sass/components/modalfor aModalwith a card wants it too. -
components/paginationdraws the page links' keyboard focus ring, which Bulma's own styles turn off, keeps the current page marked in forced colors (Windows' contrast themes), and draws a disabled control there at full strength in the system's disabled color, where Bulma's half opacity would fade it, so a build that usesbulma/sass/components/pagination, for aPaginationor aDataTable's pager, wants it too. -
components/tabsshows only aTabs.Content's selected panel and lays out vertical tabs, draws aTabs.Tab's keyboard focus ring and a disabled tab's look, moves Bulma's focus ring inside a link that is aTabs.Item's own child, where the tab row clips it, in the tab's text color on a selected toggle tab, brings a focused toggle tab in front of its neighbors, and keeps the active tab marked in forced colors, so a build that usesbulma/sass/components/tabsfor aTabsneeds it too. -
components/menukeeps a menu's active item marked in forced colors, drawsMenu.Section's heading and chevron, and starts each item's text at the right on a right-to-left page, so a build that usesbulma/sass/components/menu, for aMenuor aTableOfContents, wants it too. -
components/carddraws a card's edge as an outline, and the line under its header as a line, in the system's text color in forced colors, where Bulma draws both as shadows, which those themes drop, so a build that shows aCardwants it too. CheckboxCard and RadioCard draw an edge of their own and don't need it. -
components/dropdownkeeps a divider drawn in forced colors, where Bulma's fill takes the menu's own color, keeps an active item marked there the waycomponents/menudoes, and gives the open menu an edge there in place of Bulma's shadow, so a build that usesbulma/sass/components/dropdown, for aDropdownor aContextMenu, wants it too. -
components/navbarkeeps the burger's bars,Navbar.Dividerand an open dropdown's edge drawn and the active item marked in forced colors, keeps afixednavbar, or one Bulma's-touchor-desktopfixed classes fix, in place while an overlay locks the page's scrolling, pads the page's scroll by such a navbar's height so a control that takes focus doesn't scroll under it, gives an active item's text the invert of the link color it sits on, where Bulma's leaves it in the navbar's text color, draws a navbar in a coloredHeroin the hero's colors, where Bulma's draws its active item and burger in the link color, and, in a build with a class prefix, draws a dropdown's active link row, other than a tab, as it draws without one, where Bulma's draws it as a plain row, so a build that usesbulma/sass/components/navbar, for aNavbaror anAppFrame's burger, wants it too. -
components/panelkeeps the heading of a panel with no color readable on the dark scheme, where Bulma writes it white on light gray, and a colored panel's active block and tab, their text, icon and underline, readable on both schemes, and keeps the panel's edge drawn and the active block and tab marked in forced colors, so a build that usesbulma/sass/components/panelwants it too. -
elements/boxdraws a box's edge as an outline in the system's text color in forced colors, where Bulma draws it as a shadow, which those themes drop, so a build that usesbulma/sass/elements/boxwants it too. -
elements/dividerdraws aDivider's line as a border in the system's text color in forced colors, where Bulma draws an<hr>as a background color that's replaced with the page's own, so a build that shows aDivider, or a plain<hr>, wants it. An<hr>with a class of its own, such as Bulma's dropdown and navbar dividers, keeps its own rules. Bulma draws the<hr>in its base, which every build has, so it needs no Bulma module of its own. -
elements/deletegives the delete button and the Modal's floating close a target at least 24px square around the circle Bulma draws, and keeps close buttons drawn in forced colors, the delete button and the Modal's and delete tag's crosses, so a build that shows any close button wants it. Without it a press just beside a small circle misses it. -
elements/buttongives a focused button an outline where Bulma's border and shadow show nothing, on a ghost or static button, on a disabled link and on every button in forced colors, apart from a loading one, whichelements/loaderoutlines, gives a colored button a border in forced colors, where Bulma draws it with none and the fill is replaced, draws a pressedToggleButton, a checkedSegmentedControlsegment and any other button with Bulma'sis-selectedin the system's highlight colors there, where they'd look like the buttons beside them, draws a disabled button at full strength there, where Bulma's disabled opacity would fade the system's color for it, draws a linkButtonwithisDisabledthe way Bulma draws a disabled<button>, since Bulma draws only thedisabledattribute, which a link doesn't get, and gives an outlined button the lightness Bulma picks for its color's text on the page where that's lighter, so a dark color reads on the dark scheme, so a build that usesbulma/sass/elements/buttonwants it too. -
elements/loaderstops Bulma's spinners underprefers-reduced-motion: reduce, hides everything inside a loading button where Bulma hides only the label, outlines a loading button that has keyboard focus, whose focus shadow Bulma takes away, and keeps each spinner's ring open in forced colors, so a build that shows aLoaderor a loadingButton,ControlorSelectwants it too. -
elements/progresskeeps aProgressbar drawn in forced colors (Windows' contrast themes), its fill and an edge in the text color, where Bulma paints it in colors a contrast theme turns into the page's, and stops an indeterminate bar's sweep underprefers-reduced-motion: reduce, so a build that usesbulma/sass/elements/progresswants it too. -
elements/skeletonkeeps every skeleton shape (Skeleton, theskeletonprop andhasSkeleton) drawn in forced colors (Windows' contrast themes), inGrayTextwith the text Bulma hides still hidden, where a contrast theme turns Bulma's shape into the page's color and shows that text, and stops the shapes' pulse underprefers-reduced-motion: reduce, so a build that usesbulma/sass/base/skeletonwants it too. -
form/fieldputs themessageof a horizontal form component (Input horizontal,Checkboxes horizontaland the like) under its control, where Bulma's row would set it beside, and keeps a horizontal label's text against its control on a right-to-left page, so a build that usesbulma/sass/form/toolsfor horizontal fields wants it too. -
form/filelets a file dropped on aFile's button or name reach its input, where Bulma's module draws the button and name over it, draws the button's keyboard focus ring, where Bulma's transparent input shows none, and rounds the bottom corners of a boxedhasNameFile with no name to show, which Bulma'sis-boxedsquares, so a build that usesbulma/sass/form/file, for aFileor aDropzone, wants it too. -
form/selectoutlines a focusedSelectin forced colors (Windows' contrast themes), where Bulma's focus ring is a shadow those themes drop and only the border's color would change, and draws a disabled one's arrow there in the system's disabled color at full strength, so a build that usesbulma/sass/form/selectwants it too. -
helpers/colorgives a color's text (textColor,has-text-*) the color's on-scheme lightness on the dark scheme wherever that's the lighter one, so a dark color such as the bestax blue primary reads there, and a build that usesbulma/sass/helpers/colorwants it too. -
helpers/visibilitydrawsis-sr-onlyat each breakpoint, which Bulma draws only at every width and the viewport visibility props write for'sr-only'(visibilityTablet="sr-only"), so a build that usesbulma/sass/helpers/visibilityfor those props wants it too.
A partial like that can end in the same name as the Bulma module it adjusts, and Sass refuses two @use lines with the same name in one file, so load it with a name of its own, as bestax-<name>, as the example above does. The name changes nothing in the compiled CSS.
Others draw on a stock Bulma component without adjusting it.
-
components/dialogis drawn inside Bulma's modal, which makes it an overlay, with Bulma's buttons for its actions, so a build that uses it wantsbulma/sass/components/modal,bulma/sass/elements/buttonandelements/buttontoo. Without the modal module the dialog sits in the page's flow with no backdrop. ACommand.Dialogis drawn inside the modal too, andcomponents/lightbox's viewer is one as well, with the button, loader and delete modules its controls use. -
components/tableofcontentsis Bulma's menu, so a build that uses it wantsbulma/sass/components/menuandcomponents/menutoo. -
form/checkboxcardandform/radiocardare Bulma cards, so a build that uses them wantsbulma/sass/components/cardtoo. -
elements/stat'sStatsrow is Bulma's smart grid, so a build with one wantsbulma/sass/grid/gridtoo. -
form/dropzoneis Bulma's file widget, so a build that uses it wantsbulma/sass/form/fileand bestax'sform/file, for the zone's focus ring, too, and its remove buttons are delete buttons, so it wantsbulma/sass/elements/deleteandelements/deleteas well. -
layout/appframe's drawer closes with a delete button, so it wantsbulma/sass/elements/deleteandelements/deletetoo, and its burger is Bulma's navbar burger, so it wantsbulma/sass/components/navbarandcomponents/navbaras well. Its icon rail,AppFrame.Nav rail, shows each label in a tooltip, so a build with a rail wantscomponents/tooltiptoo, andbulma/sass/components/menuandcomponents/menufor the icons in its menu. -
form/colorpickerdraws its swatches and its preview withelements/colorswatch, and its value field and eye dropper button are Bulma's, so it wants that partial,bulma/sass/form/input-textareaandbulma/sass/elements/buttonas well. -
form/colorinputopens aform/colorpickerin the date pickers'form/picker-popover, so it wants both of those and what they want. -
form/passwordinputlays its button over Bulma's input, so it wantsbulma/sass/form/input-textareaas well. -
form/treeselectopens acomponents/treeviewinform/picker-popover, and its field, tags and clear button are Bulma's, so it wants those two,form/checkboxfor the boxes,bulma/sass/form/input-textarea,bulma/sass/elements/tag,bulma/sass/elements/deleteandelements/deleteas well. -
form/cascaderopens its columns inform/picker-popover, and bringsform/comboboxwith it, for its search and the values its items start from. Its items are Bulma's dropdown items, so it wantsform/picker-popover,bulma/sass/components/dropdown,bulma/sass/form/input-textarea,bulma/sass/elements/deleteandelements/deletefor the field and its clear button, andbulma/sass/elements/loader,elements/loaderandbulma/sass/elements/buttonfor a column that's loading or failed to load. -
components/tourdraws a step's Skip, Back and Next with Bulma's buttons and its close button with a delete button, so a build that uses it wantsbulma/sass/elements/button,bulma/sass/elements/deleteandelements/deletetoo.
@use '@allxsmith/bestax-bulma/scss/bestax'— SCSS source for the full combined bundle (Bulma + all extras). Use this instead ofbestax.csswhen you want a single SCSS entry point that participates in your Sass build.@use '@allxsmith/bestax-bulma/scss'— extras only (equivalent toextras.cssbut from source).
Complete example
A realistic modular SCSS entry for an app that uses a few Bulma primitives plus bestax's Dialog and Autocomplete:
// src/styles/app.scss
// Required base
@use 'bulma/sass/base';
@use 'bulma/sass/themes';
// Bulma partials — only what the app uses
@use 'bulma/sass/elements/button';
@use 'bulma/sass/elements/box';
@use 'bulma/sass/elements/title';
@use 'bulma/sass/form/input-textarea';
@use 'bulma/sass/components/card';
@use 'bulma/sass/components/modal'; // Dialog is drawn inside a Modal
@use 'bulma/sass/grid/columns';
@use 'bulma/sass/helpers/spacing';
@use 'bulma/sass/helpers/color';
// bestax extras — only what the app uses
@use '@allxsmith/bestax-bulma/scss/components/card' as bestax-card;
@use '@allxsmith/bestax-bulma/scss/elements/box' as bestax-box;
@use '@allxsmith/bestax-bulma/scss/helpers/color' as bestax-color;
@use '@allxsmith/bestax-bulma/scss/components/dialog';
@use '@allxsmith/bestax-bulma/scss/form/autocomplete';
Then import the compiled stylesheet once in your app entry:
// src/App.tsx
import './styles/app.scss';
import {
Button,
Box,
Card,
Columns,
Column,
Title,
Dialog,
Autocomplete,
} from '@allxsmith/bestax-bulma';
function App() {
return (
<Columns>
<Column>
<Card>
<Box p="4">
<Title>Modular App</Title>
<Button color="primary">Go</Button>
</Box>
</Card>
</Column>
</Columns>
);
}
export default App;
Prebuilt variants
If you want something smaller than bestax.css without writing SCSS, bestax ships a handful of prebuilt variants as a middle ground:
// Bulma + extras, all classes prefixed with `bestax-` (pair with classPrefix="bestax-")
import '@allxsmith/bestax-bulma/versions/bestax-prefixed.css';
// Combined bundle without Bulma's helper classes (saves a lot of CSS)
import '@allxsmith/bestax-bulma/versions/bestax-no-helpers.css';
// Same, `bestax-` prefixed
import '@allxsmith/bestax-bulma/versions/bestax-no-helpers-prefixed.css';
// Combined bundle without dark-mode rules
import '@allxsmith/bestax-bulma/versions/bestax-no-dark-mode.css';
These require no SCSS toolchain — swap the import path and you're done.
Bundle size expectations
bestax.css: ~800KB minified on disk, ~82KB gzipped over the wire (Bulma + extras). The raw number is what your bundler reports at build time; the gzipped number is what users download. Fine for most apps — but it ships in full regardless of how many components you use, because bundlers don't tree-shake CSS. See the full File Size Comparison for every prebuilt variation, and Optimizing CSS Size for the complete trimming playbook.- Hand-rolled modular SCSS: can cut the CSS significantly if you only use a handful of components, but expect diminishing returns after gzip.
- JS bundle: the entire library is ~65KB min+gzip, and tree shaking is automatic with named imports.
When to go modular
Use this checklist before switching away from bestax.css:
- Ship first with
bestax.css. Don't premature-optimize — many apps never need anything else. - Measure. Use
webpack-bundle-analyzer,rollup-plugin-visualizer, or your bundler's built-in stats to confirm CSS size is actually a problem — and judge by the gzipped transfer size, not the rawdist/number. - Try a prebuilt variant (
bestax-no-helpers.csssaves ~15KB gzipped,bestax-no-dark-mode.css~12KB) before reaching for SCSS — often enough to hit the target. - Only then reach for modular SCSS, and keep the imports in a single entry file so they're easy to audit as the app grows.