<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Girl who code</title>
    <description>The latest articles on Forem by Girl who code (@girlwhocode).</description>
    <link>https://forem.com/girlwhocode</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2431820%2Fc5d4255d-08f5-4785-9d16-ee5c1563b440.png</url>
      <title>Forem: Girl who code</title>
      <link>https://forem.com/girlwhocode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/girlwhocode"/>
    <language>en</language>
    <item>
      <title>Design Tokens</title>
      <dc:creator>Girl who code</dc:creator>
      <pubDate>Fri, 27 Mar 2026 18:45:52 +0000</pubDate>
      <link>https://forem.com/girlwhocode/design-tokens-23cl</link>
      <guid>https://forem.com/girlwhocode/design-tokens-23cl</guid>
      <description>&lt;p&gt;Design tokens are a single source of truth for reusable design properties, stored in such a way that computers and humans can easily read and process them. They represent core design decisions and translate them into a structured, sharable, and reusable format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of design tokens include:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Colors: primary-color: #FF5733&lt;br&gt;
Typography: font-size-large: 16px&lt;br&gt;
Spacing: spacing-sm: 8px&lt;br&gt;
Borders: border-radius-md: 4px&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Do Design Tokens Matter?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Historically, developers and designers often worked with separate tools and formats, leading to issues like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inconsistencies in design implementation.&lt;/li&gt;
&lt;li&gt;Duplication of effort when updating or scaling designs.&lt;/li&gt;
&lt;li&gt;Miscommunication between teams.&lt;/li&gt;
&lt;li&gt;By using design tokens, these issues are minimized because tokens act as a shared, universal language.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How Design Tokens Work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Core Principles&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Platform-agnostic: Stored in formats like JSON or YAML so they can be consumed by any system—web, mobile, or desktop.&lt;/li&gt;
&lt;li&gt;Scalable: Tokens allow changes to propagate easily across all designs and implementations.&lt;/li&gt;
&lt;li&gt;Customizable: Tokens can adapt to themes or user preferences, like dark mode.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Structure of Tokens for developers at work&lt;br&gt;
Tokens are often stored hierarchically, e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "color": {
    "primary": {
      "default": "#FF5733",
      "hover": "#FF7845",
      "active": "#FF4620"
    }
  },
  "typography": {
    "font-size": {
      "small": "12px",
      "medium": "16px",
      "large": "20px"
    }
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How They Benefit Designers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consistency Across Designs:&lt;/em&gt;&lt;br&gt;
A centralized repository ensures that every design adheres to brand standards.&lt;br&gt;
For example, if the brand's primary color changes, updating the token reflects this change everywhere.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Efficient Prototyping:&lt;/em&gt;&lt;br&gt;
Tokens allow designers to create prototypes that directly match the end product.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bridge to Developers:&lt;/em&gt;&lt;br&gt;
Design tokens provide a common language between design tools (like Figma or Adobe XD) and development tools.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Supports Dynamic Design Systems:&lt;/em&gt;&lt;br&gt;
For responsive or adaptive designs, tokens enable scalability (e.g., changing spacing or font sizes across devices).&lt;/p&gt;

&lt;p&gt;** ## How They Benefit Developers**&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Reduced Manual Work:&lt;/em&gt;&lt;br&gt;
Developers can pull tokens from a shared library instead of hardcoding values.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Improved Scalability:&lt;/em&gt;&lt;br&gt;
When the design changes (e.g., a new color scheme for a theme), tokens enable quick updates without hunting down all instances.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cross-Platform Consistency:&lt;/em&gt;&lt;br&gt;
A single set of tokens can be applied across web, iOS, and Android platforms.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Facilitates Theming:&lt;/em&gt;&lt;br&gt;
Tokens can be used to define multiple themes (e.g., light mode, dark mode, brand variations).&lt;/p&gt;
&lt;h2&gt;
  
  
  How Design Tokens Fit into Design Systems
&lt;/h2&gt;

&lt;p&gt;Design tokens are a foundational element of design systems, which are comprehensive collections of reusable components, patterns, and guidelines.&lt;/p&gt;

&lt;p&gt;Tokens provide:&lt;/p&gt;

&lt;p&gt;Atomic definitions (e.g., colors, fonts, spacing) that feed into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Components (buttons, cards, etc.)&lt;/li&gt;
&lt;li&gt;Patterns (layouts, grids)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
If a button uses primary-color for its background, updating the token instantly changes all buttons across the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools for Managing Design Tokens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Design Tools:&lt;/em&gt;&lt;br&gt;
Figma Tokens Plugin: Automates token management within Figma.&lt;br&gt;
Adobe XD: Allows exporting assets as tokens.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Token Management Platforms:&lt;/em&gt;&lt;br&gt;
Style Dictionary: A tool by Amazon for transforming and managing tokens for multiple platforms.&lt;br&gt;
Token Studio: Focuses on synchronizing design tokens between tools.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Development Frameworks:&lt;/em&gt;&lt;br&gt;
Tailwind CSS: Utilizes a token-like approach with utility-first CSS.&lt;br&gt;
Theme UI: Integrates tokens for React-based theming.&lt;/p&gt;

&lt;p&gt;Practical Example: Button Styling with Tokens&lt;br&gt;
Imagine styling a button component using tokens:&lt;/p&gt;

&lt;p&gt;Design Token Definition (JSON):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "color": {
    "button": {
      "background": "#3498db",
      "text": "#ffffff"
    }
  },
  "spacing": {
    "padding": "12px 24px"
  },
  "border": {
    "radius": "8px"
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS Using Tokens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.button {
  background-color: var(--color-button-background);
  color: var(--color-button-text);
  padding: var(--spacing-padding);
  border-radius: var(--border-radius);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React Component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Button = () =&amp;gt; (
  &amp;lt;button className="button"&amp;gt;Click Me&amp;lt;/button&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: Changing the color.button.background token in JSON changes the button's background color everywhere.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Design Tokens Make Life Easier
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;For Designers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Streamlined workflows.&lt;/li&gt;
&lt;li&gt;Fewer handoffs and iterations with developers.&lt;/li&gt;
&lt;li&gt;Easier brand updates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For Developers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster implementation and reduced bugs.&lt;/li&gt;
&lt;li&gt;Unified experience across platforms.&lt;/li&gt;
&lt;li&gt;Simplified maintenance and scaling.&lt;/li&gt;
&lt;li&gt;In short, design tokens bridge the gap between design and development, improving collaboration and ensuring consistency. They're indispensable for modern, scalable design systems.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ui</category>
      <category>ux</category>
      <category>uxdesign</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Controlled vs Uncontrolled Components in React</title>
      <dc:creator>Girl who code</dc:creator>
      <pubDate>Sun, 15 Dec 2024 06:50:55 +0000</pubDate>
      <link>https://forem.com/girlwhocode/controlled-vs-uncontrolled-components-in-react-43f5</link>
      <guid>https://forem.com/girlwhocode/controlled-vs-uncontrolled-components-in-react-43f5</guid>
      <description>&lt;p&gt;Controlled Components: React Components that control the state of form elements via state or props, i.e., every state mutation will have an associated handler function.&lt;/p&gt;

&lt;p&gt;Characteristics&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Value controlled by state - element value is bound to state variable&lt;/li&gt;
&lt;li&gt;Requires event handler - To update the state you need event handler&lt;/li&gt;
&lt;li&gt;Predictable - Since the component state represents the input value, the component is predictable and easy to debug&lt;/li&gt;
&lt;li&gt;React Handles the input data and doesn't rely on DOM to keep track of the current input value
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';

function ControlledForm() {
  const [value, setValue] = useState('');

  const handleChange = (event) =&amp;gt; {
    setValue(event.target.value);
  };

  return (
    &amp;lt;form&amp;gt;
      &amp;lt;input 
        type="text" 
        value={value} 
        onChange={handleChange} 
      /&amp;gt;
    &amp;lt;/form&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Uncontrolled Components: React Component where DOM itself handles the form element's state. React accesses the input value via ref, which stores its own state internally, and you query the DOM using a ref to find its current value when you need it. This is a bit more like traditional HTML.&lt;/p&gt;

&lt;p&gt;Characteristics&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Value controlled by DOM - The input field's value is not bound to a state variable.&lt;/li&gt;
&lt;li&gt;Uses Ref to access a value or to get the value of input element when needed&lt;/li&gt;
&lt;li&gt;They are simpler to set up if you don't need real-time control over input.&lt;/li&gt;
&lt;li&gt;Suitable for scenarios where react state isn't required to control the input.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useRef } from 'react';

function UncontrolledForm() {
  const inputRef = useRef();

  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    alert('Input Value: ' + inputRef.current.value);
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;input type="text" ref={inputRef} /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a comparison table between controlled and uncontrolled components:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg26y1n6unfguiiigox6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg26y1n6unfguiiigox6.png" alt="Image description" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use when&lt;/strong&gt;&lt;br&gt;
Controlled - for real-time validations, input formatting, or immediate feedback.&lt;br&gt;
Uncontrolled - used for simple use cases like file uploads pre-filled form value isn't frequent or needs to be deferred until form submission.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>interview</category>
      <category>react</category>
    </item>
  </channel>
</rss>
