|
1 | | -<ComingSoon /> |
| 1 | +--- |
| 2 | +title: "Bulma (Flexbox-First Framework)" |
| 3 | +description: "Explore Bulma, a modern, lightweight, and responsive CSS framework based entirely on Flexbox, offering intuitive components and an easy-to-read utility class structure." |
| 4 | +keywords: [Bulma CSS, Flexbox framework, CSS components, responsive design, modular CSS, lightweight framework] |
| 5 | +tags: [Bulma CSS, Flexbox framework, CSS components, responsive design, modular CSS, lightweight framework] |
| 6 | +sidebar_label: Bulma |
| 7 | +--- |
| 8 | + |
| 9 | +Bulma is a modern, open-source CSS framework that distinguishes itself by being built entirely on **Flexbox**. Unlike older frameworks, Bulma is purely CSS, it provides no built-in JavaScript components, making it lightweight and easy to integrate with any JavaScript framework (React, Vue, Angular, etc.). |
| 10 | + |
| 11 | +Bulma is known for its highly readable class names and its strong focus on a clean, modular component architecture, offering a refreshing alternative to larger, more traditional frameworks. |
| 12 | + |
| 13 | +<AdsComponent /> |
| 14 | +<br /> |
| 15 | + |
| 16 | +## 1. Core Philosophy: Pure CSS and Modularity |
| 17 | + |
| 18 | +Bulma's core design principles prioritize simplicity and separation of concerns: |
| 19 | + |
| 20 | +### A. Pure CSS |
| 21 | + |
| 22 | +Bulma consists only of CSS files. All interactive components (like dropdowns, modals, and tabs) require developers to supply their own JavaScript implementation to manage the necessary `is-active` or `is-hidden` state classes. This gives developers complete control over the front-end logic. |
| 23 | + |
| 24 | +### B. Modularity |
| 25 | + |
| 26 | +Bulma's source code is modular, broken down into 39 individual Sass files. This allows developers to easily import only the specific components they need (e.g., just the grid and buttons) to minimize the final stylesheet size. |
| 27 | + |
| 28 | +### C. Readable Class Names |
| 29 | + |
| 30 | +Bulma uses highly descriptive, hyphenated class names that are easy to remember and understand, such as `is-primary`, `is-fullwidth`, or `has-text-centered`. |
| 31 | + |
| 32 | +## 2. The Responsive Flexbox Grid |
| 33 | + |
| 34 | +Since Bulma is Flexbox-based from the ground up, its grid system is highly flexible and intuitive, relying on the `columns` and `column` classes. |
| 35 | + |
| 36 | +### A. Structure |
| 37 | + |
| 38 | +1. **Container:** `.container` (fixed width, centered) or `.is-fluid` (full width). |
| 39 | +2. **Columns Wrapper:** `.columns` initializes the Flexbox container, providing necessary negative margins and spacing. |
| 40 | +3. **Columns:** `.column` acts as the flexible item inside the wrapper. |
| 41 | + |
| 42 | +### B. Size and Breakpoints |
| 43 | + |
| 44 | +Columns are defined by using the fraction of the 12-column grid system (e.g., `is-half` for 6/12, `is-one-third` for 4/12). |
| 45 | + |
| 46 | +Bulma uses four main breakpoints: |
| 47 | + |
| 48 | +| Prefix | Breakpoint (Min-Width) | Device Type | Purpose | |
| 49 | +| :--- | :--- | :--- | :--- | |
| 50 | +| `is-mobile` | Default | Mobile (Default Stack) | Mobile-only classes. | |
| 51 | +| `is-tablet` | $\ge 769px$ | Tablet | Defines behavior for tablets and up. | |
| 52 | +| `is-desktop` | $\ge 1024px$ | Desktop | Defines behavior for desktops and up. | |
| 53 | +| `is-widescreen` | $\ge 1216px$ | Large Desktop | Defines behavior for larger screens. | |
| 54 | + |
| 55 | +### Responsive Grid Example |
| 56 | + |
| 57 | +This layout uses three equal columns on tablet size and larger, and stacks vertically on mobile. |
| 58 | + |
| 59 | +```html title="index.html" |
| 60 | +<div class="container"> |
| 61 | + <div class="columns is-desktop"> |
| 62 | + |
| 63 | + <!-- Each column takes 1/3 of the space on desktop and tablet --> |
| 64 | + <div class="column is-one-third"> |
| 65 | + <p>Column 1 (4/12)</p> |
| 66 | + </div> |
| 67 | + <div class="column is-one-third"> |
| 68 | + <p>Column 2 (4/12)</p> |
| 69 | + </div> |
| 70 | + <div class="column is-one-third"> |
| 71 | + <p>Column 3 (4/12)</p> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | +</div> |
| 75 | +``` |
| 76 | + |
| 77 | +<AdsComponent /> |
| 78 | +<br /> |
| 79 | + |
| 80 | +## 3. Bulma Components |
| 81 | + |
| 82 | +Bulma provides clean, modern designs for common UI elements using semantic and state-based modifiers. |
| 83 | + |
| 84 | +### A. Button Modifiers |
| 85 | + |
| 86 | +Buttons use the base class `.button` and are styled using color and size modifiers. |
| 87 | + |
| 88 | +| Class Modifier | Description | Example | |
| 89 | +| :--- | :--- | :--- | |
| 90 | +| `is-primary` | Primary brand color. | `<button class="button is-primary">` | |
| 91 | +| `is-danger` | Red/Error color. | `<button class="button is-danger is-light">` | |
| 92 | +| `is-large` | Increases button size. | `<button class="button is-info is-large">` | |
| 93 | +| `is-loading` | Adds a loader/spinner visual. | `<button class="button is-loading">` | |
| 94 | + |
| 95 | +### B. Media Object |
| 96 | + |
| 97 | +A classic example of Bulma's modularity is the `media-object`, perfect for comments, tweets, or user listings. |
| 98 | + |
| 99 | +```html title="index.html" |
| 100 | +<article class="media"> |
| 101 | + <figure class="media-left"> |
| 102 | + <p class="image is-64x64"> |
| 103 | + <img src="https://placehold.co/128x128/ccc/fff?text=P" alt="Profile"> |
| 104 | + </p> |
| 105 | + </figure> |
| 106 | + <div class="media-content"> |
| 107 | + <div class="content"> |
| 108 | + <p> |
| 109 | + <strong>John Doe</strong> <small>@jdoe</small> <small>31m</small> |
| 110 | + <br> |
| 111 | + Bulma makes clean, simple layouts incredibly fast to build. |
| 112 | + </p> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | +</article> |
| 116 | +``` |
| 117 | + |
| 118 | +<AdsComponent /> |
| 119 | +<br /> |
| 120 | + |
| 121 | +## 4. Utility Helpers (Modifiers) |
| 122 | + |
| 123 | +Bulma relies heavily on helper classes to control state, color, and positioning. Many of these are prefixed with `is-` or `has-`. |
| 124 | + |
| 125 | +| Helper Category | Example Class | CSS Property / Use | |
| 126 | +| :--- | :--- | :--- | |
| 127 | +| **Color** | `has-text-success`, `has-background-info` | Sets text color or background color using the predefined color palette. | |
| 128 | +| **Text Alignment** | `has-text-centered`, `has-text-right-tablet` | Controls text alignment, including responsive variants. | |
| 129 | +| **Sizing** | `is-fullwidth`, `is-half` | Sets width properties (e.g., `width: 100%`). | |
| 130 | +| **State** | `is-active`, `is-hidden` | Used to toggle visibility or state, typically controlled by JavaScript. | |
| 131 | + |
| 132 | +### Example using Helpers |
| 133 | + |
| 134 | +```html title="index.html" |
| 135 | +<div class="notification is-danger is-light has-text-centered"> |
| 136 | + <button class="delete"></button> |
| 137 | + This action failed. Please check your credentials. |
| 138 | +</div> |
| 139 | +``` |
| 140 | + |
| 141 | +:::info Customization |
| 142 | +The most scalable way to customize Bulma is by using its provided Sass variables. By overriding the `$primary`, `$link`, and `$gap` variables in a custom SCSS file before importing the framework, you can apply your brand identity globally without touching Bulma's core files. |
| 143 | +::: |
| 144 | + |
| 145 | +## Try It Yourself |
| 146 | + |
| 147 | +Now that you've seen some of Bulma's core features, try building a simple layout with a navigation bar, a hero section, and a grid of cards using the framework's components and helpers. |
| 148 | + |
| 149 | +<CodePenEmbed |
| 150 | + title="CodeHarborHub Bulma Demo" |
| 151 | + penId="EaKOKQy" |
| 152 | +/> |
| 153 | + |
| 154 | +## 5. Resources for Further Learning |
| 155 | + |
| 156 | +To dive deeper into Bulma and explore its full feature set, here are some helpful resources to assist you in building and navigating content. |
| 157 | + |
| 158 | +### Official Documentation |
| 159 | + |
| 160 | +The official documentation is the single most important resource, offering detailed explanations and live examples for every component and helper. |
| 161 | + |
| 162 | +* Main Documentation: https://bulma.io/documentation/ |
| 163 | +* Getting Started Guide: https://bulma.io/documentation/overview/start/ |
| 164 | + |
| 165 | +### Community and Source Code |
| 166 | + |
| 167 | +* Bulma GitHub Repository: View the source code, contribute, or report bugs on the official repository. https://github.com/jgthms/bulma |
| 168 | +* Bulma Expo: A collection of websites and projects built with Bulma, great for design inspiration. https://bulma.io/expo/ |
0 commit comments