Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Automating Design Systems: Tips And Resources For Getting Started

      August 6, 2025

      OpenAI releases two open weight reasoning models

      August 6, 2025

      Accelerate tool adoption with a developer experimentation framework

      August 6, 2025

      UX Job Interview Helpers

      August 5, 2025

      Yes, you can edit video like a pro on Linux – here are my 4 go-to apps

      August 6, 2025

      I tried Perplexity’s new reservation feature, and it surprised me with new dining spots to try

      August 6, 2025

      Your Samsung TV is getting a huge feature upgrade – 3 AI tools launching right now

      August 6, 2025

      This multi-card reader is one of the best investments I’ve made for my creative workflow

      August 6, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Fluent Object Operations with Laravel’s Enhanced Helper Utilities

      August 6, 2025
      Recent

      Fluent Object Operations with Laravel’s Enhanced Helper Utilities

      August 6, 2025

      Record and Replay Requests With Laravel ChronoTrace

      August 6, 2025

      How to Write Media Queries in Optimizely Configured Commerce (Spire)

      August 6, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Battlefield 6 Developers Confirm AI Bots Will Auto-fill Servers If Player Count Drops

      August 6, 2025
      Recent

      Battlefield 6 Developers Confirm AI Bots Will Auto-fill Servers If Player Count Drops

      August 6, 2025

      Canon imageFORMULA R40 Driver for Windows 11, 10 (Download)

      August 6, 2025

      Microsoft to End Support for Visual Studio 2015 This October

      August 6, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to Write Media Queries in Optimizely Configured Commerce (Spire)

    How to Write Media Queries in Optimizely Configured Commerce (Spire)

    August 6, 2025

    Media queries are essential for modern websites. They enable responsive design by allowing your site or UI to adapt seamlessly across different device sizes. In this blog, we’ll explore how to implement media queries in Optimizely Spire and how to update or customize breakpoints to suit your design needs.

    Let’s get started!

    Setting Up Breakpoints

    First, we’ll define breakpoints based on our style guide. Breakpoints help your website adjust its layout depending on the screen size, such as mobile, tablet, or desktop.

    In Optimizely Spire, breakpoints are defined within the theme configuration file. To update these breakpoints in the base code, you need to create a Start.tsx file—if it hasn’t been made already.

    Path: modules/blueprints/CustomBlueprint/src/Start.tsx

    Where to Place Breakpoint Configuration

    Place the breakpoint configuration within either the setPreStyleGuideTheme or setPostStyleGuideTheme functions. These functions allow you to customize the theme before or after the default style guide is applied.

    This setup ensures that your custom breakpoints are recognized and used consistently throughout your application.

    Below is the configuration structure for setting custom breakpoints in Optimizely Spire:

    Breakpoint Configured commerce

    Understanding the Breakpoint Configuration

    To make your site responsive, you define breakpoints—specific screen widths where your layout should adapt. Here’s what each part of the configuration means:

    • Keys – Represent screen size labels such as:

    These are shorthand names for different device sizes:

      • xs – Extra small (e.g., small phones)
      • sm – Small (e.g., larger phones)
      • md – Medium (e.g., tablets)
      • lg – Large (e.g., small laptops)
      • xl – Extra large (e.g., large desktops)
    • Values – Minimum Widths

    These define when each screen size category starts:

      • xs starts at 0px
      • sm starts at 576px
      • md starts at 768px
      • lg starts at 992px
      • xl starts at 1200px
    • Max Widths – Content Limits

    These define the maximum width the content area can grow to at each breakpoint. Even if the screen is wider, the content won’t stretch beyond these limits (example: 1140px for xl).

    Think of it like this:

    • On a phone → small screen → use xs styles
    • On a tablet → medium screen → use md styles
    • On a laptop or desktop → big screen → use lg or xl styles

    Creating Media Queries in a Standardized Way

    To create media queries in Optimizely Spire, we rely on the breakpoint configuration defined earlier. This ensures consistency across the application and simplifies responsive design.

    How It Works

    Behind the scenes, Spire uses a utility called breakpointMediaQueries to convert standardized media query definitions into browser-readable CSS.

    Utility Location:  modulesmobiussrcutilitiesbreakpointMediaQueries.ts

    This utility helps generate clean and consistent media queries based on your defined breakpoints.

    Available Media Query Types:

    Here are three types of media query options available:

    • min – Applies styles when the screen is at or above a certain width.
    • max – Applies styles when the screen is at or below a certain width.
    • minMax – Applies styles between two specific widths.

    Default Media Query Structure

    Here’s what a typical media query definition looks like using this utility:

    Media query structure configured commerce

    Now let’s see how this media query utility works with min, max, and minMax.

    • min

    The min-width media query structure will be as follows:

    Min Width media query configured commerce

     Example: To apply styles for min-width: 576px, insert your CSS code in the appropriate section.                                               Min Width media query example configured commerce

    Similarly, if you want to apply CSS for min-width: 768px, just replace the respective null with your CSS code.

    • max

    The max-width media query structure will be as follows:

    Max Width media query configured commerce

    Example: To apply styles for max-width: 575px, insert your CSS code in the appropriate section.Max Width media query example configured commerce

    Similarly, if you want to apply CSS for max-width: 767px, just replace the respective null with your CSS code.

    • minMax

    The minMax media query structure will be as follows:minMax Width media query example configured commerce

    Example: To apply styles between min-width: 576px and max-width: 767px, insert your CSS code in the appropriate section.minMax Width media query example configured commerce

     

    Similarly, if you want to create media queries for other screen sizes, follow the same approach as described above.

    You can also define multiple CSS rules as shown in the examples below.

    With Multiple Css Option configured commerce

    Conclusion

    Creating responsive layouts doesn’t have to be complicated or repetitive. A utility like breakpointMediaQueries helps you apply consistent styling logic throughout your application. Whether you use a mobile-first (min), desktop-first (max), or range-based (minMax) approach, this system lets you apply styles exactly where they’re needed.

    By simplifying the media query logic, your code becomes easier to read and maintain, so you can focus more on design and less on repetitive code. Choose the approach that best fits your project, and let your breakpoints handle the rest.

     

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleBuilding a Custom API with Node.js
    Next Article JavaScript vs C#: How to Choose the Right Language as a Beginner

    Related Posts

    Development

    Fluent Object Operations with Laravel’s Enhanced Helper Utilities

    August 6, 2025
    Development

    Record and Replay Requests With Laravel ChronoTrace

    August 6, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-4474 – WordPress Frontend Dashboard Plugin Privilege Escalation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Tiny Screens, Big Impact: The Forgotten Art Of Developing Web Apps For Feature Phones

    Tech & Work

    8 Large Open-Source Projects Built with Plain PHP (No Framework)

    Development

    CVE-2025-31249 – Apple macOS Sequoia Logic Flaw Allows Sensitive Data Exposure

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-5395 – WordPress Automatic Plugin Unvalidated File Upload Vulnerability

    June 11, 2025

    CVE ID : CVE-2025-5395

    Published : June 11, 2025, 7:15 a.m. | 2 hours, 37 minutes ago

    Description : The WordPress Automatic Plugin plugin for WordPress is vulnerable to arbitrary file uploads due to insufficient file type validation in the ‘core.php’ file in all versions up to, and including, 3.115.0. This makes it possible for authenticated attackers, with Author-level access and above, to upload arbitrary files on the affected site’s server which may make remote code execution possible.

    Severity: 8.8 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-20666 – “Modem Rogue Base Station Denial of Service Vulnerability”

    May 4, 2025

    BeyondTrust PRA Vulnerability (CVE-2025-0217) Enables Session Hijacking via Authentication Bypass

    May 5, 2025

    Legion Go S is the cheapest Windows handheld gaming PC right now during Prime Day — I still wouldn’t buy it, I’d buy this other one instead

    July 8, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.