Skip to main content

Visibility

Bulma provides comprehensive visibility helpers to control how elements are displayed and hidden across different screen sizes and contexts. These utilities are essential for responsive design and accessibility.

Composable hook

These props are also available standalone via the useVisibilityClasses hook — see Composable Mini-Hooks.

Reference

This page documents the bestax-bulma prop API for Bulma's visibility helpers. For the underlying CSS utilities, see the official Bulma visibility helpers.

tip

Most components in bestax-bulma take these visibility properties through the useBulmaClasses hook, so check a component's props before passing one.

Display​

Control the CSS display property using the display prop or viewport-specific display properties. This determines how an element is displayed in the document flow.

Basic Display Properties​

PropertyBulma ClassDescription
display="block"is-blockBlock-level element (full width, new line)
display="flex"is-flexFlexbox container
display="inline"is-inlineInline element (flows with text)
display="inline-block"is-inline-blockInline element that can have width/height
display="inline-flex"is-inline-flexInline flexbox container
display="none"is-hiddenElement is completely hidden

Viewport-Specific Display Properties​

For responsive layouts requiring different display types across viewports, use the viewport-specific display properties:

PropertyBulma Class PatternTarget Viewport
displayMobileis-{display}-mobileUp to 768px
displayTabletis-{display}-tablet769px and above
displayTabletOnlyis-{display}-tablet-only769px - 1023px
displayTouchis-{display}-touchUp to 1023px
displayDesktopis-{display}-desktop1024px and above
displayDesktopOnlyis-{display}-desktop-only1024px - 1215px
displayWidescreenis-{display}-widescreen1216px and above
displayWidescreenOnlyis-{display}-widescreen-only1216px - 1407px
displayFullhdis-{display}-fullhd1408px and above

Example: displayMobile="flex" generates is-flex-mobile, displayDesktop="none" generates is-hidden-desktop

These properties' ranges overlap: displayTablet, displayDesktop and displayWidescreen run from their breakpoint up, displayTouch covers mobile and tablet, and an Only property sits inside the plain one for its breakpoint. Where two overlap, the breakpoint doesn't decide which wins. none does, on either side, and between two display values the later in Bulma's order (block, flex, inline, inline-block, inline-flex, grid) does. So displayTablet="none" keeps an element hidden on desktop whatever displayDesktop asks, and displayTablet="inline-block" stays inline-block there over displayDesktop="flex". To change the display at a larger breakpoint, set the smaller range with its Only property, such as displayTabletOnly="none", which writes is-hidden-tablet-only.

tip

Use viewport-specific display properties when you need different display behaviors across multiple screen sizes. The generic display + viewport pattern only supports one viewport combination at a time.

Display Examples​

import { Box, Button, Content } from '@allxsmith/bestax-bulma';

function DisplayExamples() {
  return (
    <Box p="4">
      <Content mb="4">
        <strong>Block Display:</strong> Takes full width and starts on a new
        line
      </Content>
      <Box display="block" bgColor="primary" textColor="white" p="2" mb="3">
        Block element
      </Box>

      <Content mb="4">
        <strong>Inline Display:</strong> Flows with the text content
      </Content>
      <p>
        Here is some text with an
        <Box display="inline" bgColor="info" textColor="white" px="2">
          inline element
        </Box>
        in the middle of the sentence.
      </p>

      <Content mb="4" mt="4">
        <strong>Inline-block Display:</strong> Inline but can have dimensions
      </Content>
      <p>
        Text with
        <Box
          display="inline-block"
          bgColor="success"
          textColor="white"
          p="2"
          mr="1"
        >
          inline-block
        </Box>
        elements that can have padding and margins.
      </p>

      <Content mb="4" mt="4">
        <strong>Flex Display:</strong> Creates a flex container
      </Content>
      <Box display="flex" mb="3">
        <Button color="primary" mr="3">
          Flex Item 1
        </Button>
        <Button color="info" mr="3">
          Flex Item 2
        </Button>
        <Button color="success">Flex Item 3</Button>
      </Box>

      <Content mb="4">
        <strong>Inline-flex Display:</strong> Inline flex container
      </Content>
      <p>
        Text with
        <Box display="inline-flex">
          <Button size="small" color="warning" mr="2">
            A
          </Button>
          <Button size="small" color="danger">
            B
          </Button>
        </Box>
        inline flex elements.
      </p>
    </Box>
  );
}

Viewport-Specific Display Examples​

import { Box, Notification, Content } from '@allxsmith/bestax-bulma';

function ViewportDisplayExamples() {
  return (
    <Box p="4">
      <Notification color="info" mb="4">
        Resize your browser window to see elements change their display type at
        different screen sizes.
      </Notification>

      <Content mb="4">
        <strong>Progressive Display Changes:</strong> Different display types
        across viewports
      </Content>
      <Box
        displayMobile="block"
        displayTabletOnly="inline-block"
        displayDesktop="flex"
        p="3"
        mb="3"
      >
        <Notification color="primary" mb="2">
          Mobile: block | Tablet: inline-block | Desktop+: flex
        </Notification>
        <Notification color="link" mb="2">
          Item 2 (flex layout on desktop+)
        </Notification>
      </Box>

      <Content mb="4">
        <strong>Mobile Hidden, Desktop Visible:</strong> Show/hide across
        viewports
      </Content>
      <Box displayTouch="none" mb="3">
        <Notification color="success">
          📱 Hidden on mobile/tablet, visible on desktop and larger
        </Notification>
      </Box>

      <Content mb="4">
        <strong>Responsive Flex Layout:</strong> Block on mobile, flex on larger
        screens
      </Content>
      <Box displayMobile="block" displayTablet="flex" p="3" mb="3">
        <Notification color="warning" mr="2" mb="2">
          Stacked on mobile
        </Notification>
        <Notification color="danger" mr="2" mb="2">
          Side-by-side on tablet+
        </Notification>
        <Notification color="info" mb="2">
          Responsive layout
        </Notification>
      </Box>
    </Box>
  );
}

Show/Hide Elements​

Control element visibility across different screen sizes using responsive display helpers. You can show or hide elements on specific viewports using either the generic pattern or viewport-specific properties.

Generic Display + Viewport Pattern​

For simple show/hide scenarios affecting a single viewport, use the display + viewport combination:

<>
  <p>Show only on desktop and larger</p>
  <Box display="none" viewport="touch">
    Desktop+ only content
  </Box>
  <p>Hide only on mobile</p>
  <Box display="none" viewport="mobile">
    Hidden on mobile
  </Box>
</>

Limitation

The generic display + viewport pattern only supports one viewport combination at a time. You cannot chain multiple display/viewport pairs on the same element.

For complex responsive behavior requiring different display types across multiple viewports, use the viewport-specific display properties:

import { Box } from '@allxsmith/bestax-bulma';

function ViewportSpecificExample() {
  return (
    <Box p="4">
      <Box
        displayMobile="none"
        displayTablet="block"
        displayDesktop="flex"
        bgColor="primary"
        textColor="white"
        p="3"
      >
        Hide on mobile, show as block on tablet, flex on desktop+
      </Box>
    </Box>
  );
}

Choosing the Right Approach​

When to Use Generic Display + Viewport​

✅ Use when you need simple single-viewport control:

import { Box } from '@allxsmith/bestax-bulma';

function GenericDisplayExample() {
  return (
    <Box p="4">
      <Box
        display="none"
        viewport="mobile"
        bgColor="warning"
        textColor="dark"
        p="3"
        mb="3"
      >
        Hidden on mobile only
      </Box>
      <Box
        display="none"
        viewport="touch"
        bgColor="success"
        textColor="white"
        p="3"
      >
        Desktop and up only
      </Box>
    </Box>
  );
}

When to Use Viewport-Specific Properties​

✅ Use when you need multiple viewport behaviors:

import { Box, Notification } from '@allxsmith/bestax-bulma';

function MultipleViewportExample() {
  return (
    <Box p="4">
      <Box
        displayMobile="none"
        displayTablet="block"
        displayDesktop="flex"
        p="3"
        mb="3"
      >
        <Notification color="primary" mr="2" mb="2">
          Different displays across multiple viewports
        </Notification>
        <Notification color="info" mb="2">
          Hidden on mobile, block on tablet, flex on desktop
        </Notification>
      </Box>

      <Box
        displayMobile="block"
        displayTabletOnly="inline-block"
        displayDesktop="flex"
        p="3"
      >
        <Notification color="success" mr="2" mb="2">
          Progressive layout enhancement
        </Notification>
        <Notification color="warning" mb="2">
          Stacked → inline-block → flex
        </Notification>
      </Box>
    </Box>
  );
}

Precedence Rule

When both patterns are used together, viewport-specific properties take precedence: once any of them is set, the generic display (with or without viewport) is left out entirely, at every width, not only where the two overlap.

import { Box } from '@allxsmith/bestax-bulma';

function PrecedenceExample() {
  return (
    <Box p="4">
      <Box
        display="block"
        viewport="mobile"
        displayMobile="flex"
        bgColor="danger"
        textColor="white"
        p="3"
      >
        Will be flex on mobile, not block (viewport-specific wins!)
      </Box>
    </Box>
  );
}

Responsive Show/Hide Examples​

import { Box, Notification, Content } from '@allxsmith/bestax-bulma';

function ResponsiveShowHideExamples() {
  return (
    <Box p="4">
      <Notification color="info" mb="4">
        Resize your browser window to see elements appear and disappear at
        different screen sizes.
      </Notification>

      <Content mb="4">
        <strong>Mobile Only:</strong> Visible only on mobile devices
      </Content>
      <Box
        displayMobile="block"
        displayTablet="none"
        bgColor="primary"
        textColor="white"
        p="3"
        mb="3"
      >
        📱 Visible only on mobile (up to 768px)
      </Box>

      <Content mb="4">
        <strong>Tablet Only:</strong> Visible only on tablet devices
      </Content>
      <Box
        displayMobile="none"
        displayTablet="block"
        displayDesktop="none"
        bgColor="info"
        textColor="white"
        p="3"
        mb="3"
      >
        📱 Visible only on tablet (769px - 1023px)
      </Box>

      <Content mb="4">
        <strong>Desktop Only:</strong> Visible only on desktop screens
      </Content>
      <Box
        displayTouch="none"
        displayWidescreen="none"
        bgColor="success"
        textColor="white"
        p="3"
        mb="3"
      >
        💻 Visible only on desktop (1024px - 1215px)
      </Box>

      <Content mb="4">
        <strong>Widescreen Only:</strong> Visible only on widescreen displays
      </Content>
      <Box
        displayTouch="none"
        displayDesktopOnly="none"
        displayFullhd="none"
        bgColor="warning"
        textColor="dark"
        p="3"
        mb="3"
      >
        🖥️ Visible only on widescreen (1216px - 1407px)
      </Box>

      <Content mb="4">
        <strong>FullHD Only:</strong> Visible only on fullHD displays
      </Content>
      <Box
        displayTouch="none"
        displayDesktopOnly="none"
        displayWidescreenOnly="none"
        bgColor="danger"
        textColor="white"
        p="3"
        mb="3"
      >
        🖥️ Visible only on fullHD (1408px and above)
      </Box>

      <Content mb="4">
        <strong>Show from Breakpoint Up:</strong> Hidden on mobile, visible from
        tablet and up
      </Content>
      <Box
        displayMobile="none"
        displayTablet="block"
        bgColor="grey"
        textColor="white"
        p="3"
        mb="3"
      >
        📱→🖥️ Hidden on mobile, visible from tablet and up
      </Box>

      <Content mb="4">
        <strong>Show up to Breakpoint:</strong> Visible on mobile and tablet,
        hidden from desktop up
      </Content>
      <Box
        displayMobile="block"
        displayTablet="block"
        displayDesktop="none"
        bgColor="black"
        textColor="white"
        p="3"
      >
        📱📱 Visible on mobile and tablet, hidden from desktop up
      </Box>
    </Box>
  );
}

Hide​

Control element hiding across different screen sizes using the visibility prop or viewport-specific display properties. This is useful for responsive design where you want to hide content on specific screen sizes.

Hide Examples​

import { Box, Card, Title, Content, Button } from '@allxsmith/bestax-bulma';

function HideExamples() {
  return (
    <Box p="4">
      <Title size="4" mb="4">
        Responsive Hide Examples
      </Title>

      <Card mb="4">
        <Card.Content>
          <Title size="5" mb="3">
            Navigation Menu
          </Title>

          {/* Desktop navigation - hidden on mobile */}
          <Box displayMobile="none" displayTablet="flex" mb="3">
            <Button color="text" mr="3">
              Home
            </Button>
            <Button color="text" mr="3">
              About
            </Button>
            <Button color="text" mr="3">
              Services
            </Button>
            <Button color="text">Contact</Button>
          </Box>

          {/* Mobile menu button - hidden on tablet+ */}
          <Button displayMobile="block" displayTablet="none" color="primary">
            ☰ Menu
          </Button>

          <Content>
            This demonstrates a responsive navigation where full menu links are
            shown on larger screens, but only a menu button is shown on mobile.
          </Content>
        </Card.Content>
      </Card>

      <Card mb="4">
        <Card.Content>
          <Title size="5" mb="3">
            Content Layout
          </Title>

          <Box display="flex">
            <Box style={{ flex: 1, marginRight: '1rem' }}>
              <Content>
                This is the main content area that's always visible.
              </Content>
            </Box>

            {/* Sidebar hidden on mobile */}
            <Box
              displayMobile="none"
              displayTablet="block"
              bgColor="light"
              textColor="dark"
              p="3"
              style={{ width: '200px' }}
            >
              <Title size="6" mb="2" textColor="dark">
                Sidebar
              </Title>
              <Content textSize="7">
                This sidebar is hidden on mobile devices but visible on tablet
                and larger screens.
              </Content>
            </Box>
          </Box>
        </Card.Content>
      </Card>

      <Card>
        <Card.Content>
          <Title size="5" mb="3">
            Progressive Content Reveal
          </Title>

          <Content mb="3">
            Basic information visible on all screen sizes.
          </Content>

          {/* Additional details hidden on mobile */}
          <Box
            displayMobile="none"
            displayTablet="block"
            bgColor="info"
            textColor="white"
            p="3"
            mb="3"
          >
            Additional details visible on tablet and larger screens.
          </Box>

          {/* Extended content hidden on mobile and tablet */}
          <Box displayTouch="none" bgColor="success" textColor="white" p="3">
            Extended content only visible on desktop and larger screens.
          </Box>
        </Card.Content>
      </Card>
    </Box>
  );
}

Other Visibility Properties​

Additional visibility utilities for specific use cases.

PropertyBulma ClassDescription
visibility="hidden"is-hiddenElement is removed from the layout
visibility="sr-only"is-sr-onlyOnly visible to screen readers
visibility="invisible"is-invisibleElement is invisible but takes up space

is-hidden comes before the display classes in Bulma's stylesheet, so visibility="hidden" with no viewport, beside a display property such as display="flex", leaves the element showing wherever that display applies. To hide it there, set the display property to 'none' instead.

Viewport-Specific Visibility Properties​

Each visibility value ('hidden', 'sr-only', 'invisible') can be scoped to a specific breakpoint using these viewport-specific props. Unlike the generic visibility + viewport pair, these can be combined on a single element to describe different behavior per viewport.

PropertyBulma Class PatternTarget Viewport
visibilityMobileis-{value}-mobileUp to 768px
visibilityTabletis-{value}-tablet769px and above
visibilityDesktopis-{value}-desktop1024px and above
visibilityWidescreenis-{value}-widescreen1216px and above
visibilityFullhdis-{value}-fullhd1408px and above

Example: visibilityMobile="hidden" generates is-hidden-mobile; visibilityDesktop="invisible" generates is-invisible-desktop.

<Box
  visibilityMobile="hidden"
  visibilityDesktop="invisible"
  bgColor="warning"
  p="3"
>
  Hidden on mobile, invisible on desktop and up, visible on tablet.
</Box>

Bulma draws is-sr-only at every width only, so 'sr-only' at a breakpoint (visibilityTablet="sr-only", which writes is-sr-only-tablet) comes from bestax's own helpers/visibility partial, in bestax.css, extras.css and every flavor but the no-helpers ones, which leave it out with the rest of the helpers.

Other Visibility Examples​

function OtherVisibilityExamples() {
  return (
    <Box p="4">
      <Title size="4" mb="4">
        Other Visibility Properties
      </Title>

      <Content mb="4">
        <strong>Hidden vs Invisible:</strong> Both make elements not visible;
        only invisible keeps its space in the layout.
      </Content>

      <Box display="flex" mb="4">
        <Button color="primary" mr="3">
          Visible Button
        </Button>
        <Button visibility="hidden" color="info" mr="3">
          Hidden Button
        </Button>
        <Button color="success">Another Visible Button</Button>
      </Box>

      <Box display="flex" mb="4">
        <Button color="primary" mr="3">
          Visible Button
        </Button>
        <Button visibility="invisible" color="warning" mr="3">
          Invisible Button
        </Button>
        <Button color="danger">Another Visible Button</Button>
      </Box>

      <Content mb="4">
        <strong>Screen Reader Only:</strong> Content that's only accessible to
        screen readers for better accessibility.
      </Content>

      <Box>
        <Icon name="star" ariaLabel="Star rating" />
        <Span visibility="sr-only">This product has a 5-star rating</Span>
        <Icon name="star" ariaLabel="Star rating" />
        <Span visibility="sr-only">out of 5 stars</Span>
        <Icon name="star" ariaLabel="Star rating" />
      </Box>

      <Content mt="4" textSize="7" textColor="grey">
        The text between the stars is only visible to screen readers, providing
        context for users with visual impairments.
      </Content>
    </Box>
  );
}

Accessibility Considerations​

info

When hiding content, consider the accessibility implications:

  • visibility="hidden": Content is not visible and not accessible to screen readers
  • visibility="invisible": Content is not visible but takes up space and is not accessible to screen readers
  • visibility="sr-only": Content is only accessible to screen readers - use this for important context
  • display="none": Content is completely removed from the document flow and accessibility tree

Accessible Hide/Show Example​

function AccessibleToggleExample() {
  const [isExpanded, setIsExpanded] = useState(false);

  return (
    <Box p="4">
      <Card>
        <Card.Content>
          <Box
            display="flex"
            justifyContent="space-between"
            alignItems="center"
            mb="3"
          >
            <Title size="5">Expandable Content</Title>
            <Button
              color="primary"
              size="small"
              onClick={() => setIsExpanded(!isExpanded)}
            >
              {isExpanded ? 'Hide' : 'Show'} Details
            </Button>
          </Box>

          <Content>
            This is always visible content that provides context.
          </Content>

          {/* Screen reader announcement */}
          <Span visibility="sr-only">
            {isExpanded
              ? 'Additional details are now visible'
              : 'Additional details are hidden'}
          </Span>

          {/* Expandable content */}
          <Box
            display={isExpanded ? 'block' : 'none'}
            mt="3"
            bgColor="light"
            textColor="dark"
            p="3"
          >
            <Content>
              This additional content can be toggled on and off. The
              implementation ensures that screen readers are properly informed
              about the state changes.
            </Content>
          </Box>
        </Card.Content>
      </Card>
    </Box>
  );
}

Mobile-First Responsive Design​

Best Practice

Use a mobile-first approach where you design for mobile by default, then progressively enhance for larger screens using viewport-specific display helpers.

import { Box, Card, Title, Content, Button } from '@allxsmith/bestax-bulma';

function MobileFirstExample() {
  return (
    <Box p="4">
      <Card>
        <Card.Content>
          {/* Mobile layout by default */}
          <Title size="4" textAlign="centered" mb="4">
            Mobile-First Design
          </Title>

          {/* Stack vertically on mobile, horizontal on tablet+ */}
          <Box displayMobile="block" displayTablet="flex">
            <Box style={{ flex: 1, marginRight: '1rem' }}>
              <Content>
                This content stacks vertically on mobile and displays
                horizontally on tablet and larger screens.
              </Content>
            </Box>

            <Box style={{ flex: 1 }}>
              <Content>
                The spacing and layout automatically adapts to different screen
                sizes using viewport-specific display utilities.
              </Content>
            </Box>
          </Box>

          {/* Simple mobile menu, complex desktop menu */}
          <Box mt="4">
            {/* Mobile: Simple button */}
            <Button
              displayMobile="block"
              displayTablet="none"
              color="primary"
              isFullwidth
            >
              Mobile Actions
            </Button>

            {/* Desktop: Multiple buttons */}
            <Box
              displayMobile="none"
              displayTablet="flex"
              justifyContent="center"
            >
              <Button color="primary" mr="2">
                Save
              </Button>
              <Button color="info" mr="2">
                Edit
              </Button>
              <Button color="warning" mr="2">
                Share
              </Button>
              <Button isOutlined>Cancel</Button>
            </Box>
          </Box>

          {/* Progressive content enhancement */}
          <Box mt="4">
            <Content>Basic content visible on all devices.</Content>

            <Box
              displayMobile="none"
              displayTablet="block"
              bgColor="light"
              textColor="dark"
              p="3"
              mt="2"
            >
              <Content textSize="7">
                Enhanced content for tablet and larger screens with additional
                context and details.
              </Content>
            </Box>

            <Box
              displayMobile="none"
              displayDesktop="block"
              bgColor="primary"
              textColor="white"
              p="3"
              mt="2"
            >
              <Content textSize="7">
                Premium content only shown on desktop and larger screens where
                there's ample space.
              </Content>
            </Box>
          </Box>
        </Card.Content>
      </Card>
    </Box>
  );
}

Learn More

For detailed API information about visibility properties, see the useBulmaClasses API documentation.

See Also​