Building Studio in Public: Using WordPress Components and Tailwind CSS in our Local Development App  - EMEL

Latest

EMEL

Wednesday, July 31, 2024

New

Building Studio in Public: Using WordPress Components and Tailwind CSS in our Local Development App 

Media Mamat Turbo July 31, 2024
At WordPress.com, our goal is to provide the best tools for WordPress developers and agencies.  We built Studio for that reason. Our free local WordPress development environment launched a few months ago; it's based on Electron and is currentl…
Read on blog or Reader
Site logo image WordPress.com News Read on blog or Reader

Building Studio in Public: Using WordPress Components and Tailwind CSS in our Local Development App 

By Antonio Sejas on July 31, 2024

At WordPress.com, our goal is to provide the best tools for WordPress developers and agencies. 

We built Studio for that reason. Our free local WordPress development environment launched a few months ago; it's based on Electron and is currently available for Mac and Windows. Plus, we have big exciting updates coming for Studio users soon.

Download Studio for free

One of the unique things about Studio is that it's an open source tool, and it has been since day one. This directly aligns with the Automattic Creed, the driving force behind what we do at WordPress.com (and all of our other Automattic brands):

I know that Open Source is one of the most powerful ideas of our generation.

For this reason, we love building in public. In our new Building Studio in Public series, we want to share some of the learnings and insights we gained from building Studio, and our hope is that some of the lessons can help you build better products.

If you want more in-depth articles about why we chose Electron, why this is an open source project, or any other question you have about Studio, leave a comment below, and we'll make it happen.

First up in this series, we'll explore how we decided to use Tailwind CSS and the WordPress components that make up Studio and why that decision gave us extra flexibility for the future of Studio.

WordPress components everywhere

Components allow developers to create reusable pieces of code that can be composed together to build complex user interfaces. They encourage a modular and declarative approach of building UIs, where each component is responsible for a single piece of functionality or user interface element.

WordPress components are a great example of that. These components allow core and extender developers to create organized, separate, and interconnected parts of the WordPress admin interface. Not only do components make development easier and more streamlined, but they are also predictable and familiar across all WordPress users. To maintain a uniform look and feel across the entire wp-admin area, it's recommended not to override the default styles of these components.

Do not confuse WordPress components with Gutenberg Blocks. While the latter are used to build WordPress frontend websites, the former are designed for building the admin interface of the WordPress site editor. They are React-based, making them versatile and applicable in any WordPress plugin or theme admin interface. They also come in handy for building different apps beyond WordPress; the only requirement is that the project uses React.

WordPress components offer a consistent style and behavior that match the WordPress admin interface out of the box, so using them in other projects outside of the WordPress ecosystem gives a familiar look and feel to the interface and user experience. 

Not only that, the components are accessible and receive constant updates and improvements. They are implemented in JavaScript as React components, which means they can be integrated into any project. Plus, by using WordPress components in Studio, developers can more easily contribute back to this open source project because Studio is using a technology they're already used to. 

To quickly find the right component and experiment with them, you can use the WordPress Storybook, an open source tool for developing system designs and creating components in isolation. Storybook even gives you sneak peeks and allows you to interact with components from other npm WordPress packages like @wordpress/dataviews. The DataViews component is intended for future use in managing lists of posts, pages, and media uploads.

a screenshot of the DataViews component in WordPress Storybook

Components in Studio

By integrating WordPress components into Studio, we ensure a familiar user experience for WordPress users––you're building WordPress with a tool that looks and feels like WordPress. 

Most buttons, dropdowns, and menus will be familiar to WordPress users, and because Studio is an open source tool, anyone with Gutenberg experience will find it much easier to understand Studio's code and contribute if they are interested.

Even though Studio is a desktop application using Electron and not a WordPress site, we recommend not overriding the styles of WordPress components. We wanted to keep them as close to Core as possible from the design phase. This approach also reduces misalignments when updating WordPress dependencies. For styling our custom React components, we used Tailwind CSS.

Tailwind CSS is a popular, utility-first CSS framework that we use to customize the styles of our custom components and modify outer styles, such as the spacing of WordPress components, using only CSS classes.

Utilizing the power of WordPress components and Tailwind CSS future-proofs the Studio app; it's easy to reuse these components for new features and app updates because they're already imported into the project in a style that suits the app.

If a screen needs a new button, we already have loads of Studio-styled buttons to choose from; we don't need to design from scratch each time a new button is needed.

Here's how we used WordPress components and Tailwind CSS to build Studio (and how you can use them for your own projects, too):

Step 1: Set up Tailwind CSS and install WordPress components

After setting up Tailwind in your project, you'll need to install WordPress components. Simply run the following command:

 npm install @wordpress/components –save 

Step 2: Import WordPress component styles

You'll need to import WordPress component styles to inject the CSS that is built into the components by default. This speeds up the process of building your project's interface.

In your main CSS file, import the Gutenberg component styles:

 @import '@wordpress/components/build-style/style.css'; 

Step 3: Customize React components with Tailwind CSS

Use the className property to apply Tailwind CSS styles. Sometimes, the ! modifier is needed to mark the style as important and override existing WordPress styles.

Take Studio's Header component, for example:

a screenshot of Studio by WordPress.com with an orange box around the header component in the site view

We're using:

  • @wordpress/react-i18n for translations.
  • @wordpress/icons to display the icons.

To use Tailwind CSS in any component, you need to pass in the utility classes to style the elements into the className React prop. Occasionally, we needed to override the outer spacing of certain components, for which we used the exclamation mark (!).

Step 4: Accessing nested elements for use across your project

With Tailwind CSS, you can use sophisticated selectors to target user interactions and nested elements within a component. This will allow you to dynamically change stylings across your project based on user and app behavior.

For example, in Studio's Demo Sites area, we change the style of the nested element's site name and badge to a grey color when the demo site expires.

a screenshot of Studio by WordPress.com with an orange box around the SnapshotRow component area

To dynamically style this component, we use [&_.badge]:text-red, where & means current element and _ means any child element. You can apply specific styles to a direct child element by using the greater-than operator, like this: [&>div]:text-red.

code showing dynamically styling WordPress components with orange arrows pointing to style child elements and disabled states

Ready to build?

By leveraging WordPress components and a few custom components with Tailwind CSS, you can significantly enhance your development process, providing a seamless and professional user experience. 

This decision allowed us to create an app that looks and feels like the WordPress interface in a way that benefits users and speeds up our development time. That's a win-win, in my book. 

If you're building WordPress sites, start developing your WordPress sites locally with the power of Studio today. It's free, it's open source, and it will effortlessly fit into your development workflow. 

Download Studio for free

Once you download Studio: Be sure to connect Studio to your WordPress.com account (free or paid) to access features like Demo Sites.

And if you want to help us build Studio, here are some GitHub issues that you can contribute to right away:

  • php_curl missing and curl_exec deactivated
  • Total and free size of filesystem reported in sites doesn't match actual values 
  • Permission issues using a theme that uses composer
Comment
You can also reply to this email to leave a comment.

WordPress.com News © 2024.
Manage your email settings or unsubscribe.

WordPress.com and Jetpack Logos

Get the Jetpack app

Subscribe, bookmark, and get real‑time notifications - all from one app!

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com Logo and Wordmark title=

Automattic, Inc.
60 29th St. #343, San Francisco, CA 94110

Read more

Subscribe via email

Share This:
Facebook Twitter Google+ Pinterest Linkedin
Author Image

About Media Mamat Turbo
Templatesyard is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design. The main mission of templatesyard is to provide the best quality blogger templates.

By Media Mamat Turbo at July 31, 2024
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Popular

  • Meet Jetpack: Fueling Your WordPress.com Website
    Meet Jetpack: Fueling Your WordPress.com Website
    No matter what type of website you want to build, WordPress.com has all the tool...
  • This Weeks New Digital Building Blog Post
    MAMAT, check out this weeks new Digital Building Blog. ...
  • 8 Must-Try AI Tools for Web Development (Build Faster & Smarter)
    8 Must-Try AI Tools for Web Development (Build Faster & Smarter)
    Artificial intelligence excels at automating repetitive tasks and streamlining t...
  • Why Alt Text Matters: Boost Accessibility and SEO with Every Image
    The internet is a treasure trove of visuals, overflowing with inspiration and in...
  • [New post] Level Up Your Author HQ With GoCreate.Me
    David Gaughran posted: " Author websites are an increasingly important tool, but one that can cause a lot of aggravation. W...

Sponsor

Powered by Blogger.

Blog Archive

  • December 2025 (8)
  • November 2025 (19)
  • October 2025 (11)
  • September 2025 (16)
  • August 2025 (22)
  • July 2025 (19)
  • June 2025 (13)
  • May 2025 (21)
  • April 2025 (32)
  • March 2025 (32)
  • February 2025 (20)
  • January 2025 (44)
  • December 2024 (15)
  • November 2024 (17)
  • October 2024 (14)
  • September 2024 (18)
  • August 2024 (19)
  • July 2024 (14)
  • June 2024 (21)
  • May 2024 (17)
  • April 2024 (24)
  • March 2024 (29)
  • February 2024 (24)
  • January 2024 (63)
  • December 2023 (32)
  • November 2023 (29)
  • October 2023 (25)
  • September 2023 (33)
  • August 2023 (21)
  • July 2023 (21)
  • June 2023 (29)
  • May 2023 (19)
  • April 2023 (14)
  • March 2023 (16)
  • February 2023 (18)
  • January 2023 (16)
  • December 2022 (20)
  • November 2022 (24)
  • October 2022 (22)
  • September 2022 (19)
  • August 2022 (24)
  • July 2022 (31)
  • June 2022 (34)
  • May 2022 (31)
  • April 2022 (37)
  • March 2022 (28)
  • February 2022 (31)
  • January 2022 (39)
  • December 2021 (35)
  • November 2021 (37)
  • October 2021 (32)
  • September 2021 (18)
  • August 2021 (48)
  • July 2021 (43)
  • June 2021 (44)
  • May 2021 (65)
  • April 2021 (72)
  • March 2021 (64)
  • February 2021 (50)
  • January 2021 (47)
  • December 2020 (47)
  • November 2020 (43)
  • October 2020 (96)
  • September 2020 (100)
  • August 2020 (128)
  • July 2020 (87)
  • June 2020 (108)
  • May 2020 (107)
  • April 2020 (90)
  • March 2020 (91)
  • February 2020 (77)
  • January 2020 (88)
  • December 2019 (105)
  • November 2019 (107)
  • October 2019 (102)
  • September 2019 (98)
  • August 2019 (118)
  • July 2019 (115)
  • June 2019 (99)
  • May 2019 (115)
  • April 2019 (103)
  • March 2019 (112)
  • February 2019 (118)
  • January 2019 (109)
  • December 2018 (106)
  • November 2018 (128)
  • October 2018 (97)
  • September 2018 (126)
  • August 2018 (59)
  • January 2013 (1)

Search This Blog

Popular Posts

  • Meet Jetpack: Fueling Your WordPress.com Website
    Meet Jetpack: Fueling Your WordPress.com Website
    No matter what type of website you want to build, WordPress.com has all the tool...
  • This Weeks New Digital Building Blog Post
    This Weeks New Digital Building Blog Post
    MAMAT, check out this weeks new Digital Building Blog. ...
  • 8 Must-Try AI Tools for Web Development (Build Faster & Smarter)
    8 Must-Try AI Tools for Web Development (Build Faster & Smarter)
    Artificial intelligence excels at automating repetitive tasks and streamlining t...
  • Why Alt Text Matters: Boost Accessibility and SEO with Every Image
    Why Alt Text Matters: Boost Accessibility and SEO with Every Image
    The internet is a treasure trove of visuals, overflowing with inspiration and in...
Crafted with by TemplatesYard