Unicode symbol for Firefox paired with checkbox

I have been experimenting with creating a Component for Selectors (checkboxes and radios) using just css and unicode symbols as the style, rather than the default styling.

Here are some of the unicode symbols I have used:

https://i.sstatic.net/7haCW.png

If you want to check out the code, you can view it here: https://stackblitz.com/edit/unicode-selectors?file=index.js

Although everything seems to be working fine, there is an issue in Firefox (and possibly other browsers)...

In Firefox, these unicode symbols appear distorted and of different sizes, making them look very unattractive. Can anyone offer assistance on how to resolve this issue?

Here is how it looks in Firefox:

https://i.sstatic.net/umVpJ.png

To access the code directly, click here: 💻https://stackblitz.com/edit/unicode-selectors?file=index.js

Selector Component

import React from 'react'
import PropTypes from 'prop-types'

import './styles.scss'

export default function Selector({
  id, children, labelProps, selectorType, ...props
}) {
  const labelClassName = labelProps.className
  const selector = (
    <>
      <input
        className={`${selectorType}-hidden`}
        id={id}
        type={selectorType}
        {...props}
      />
      <span className="mask" />
    </>
  )

  /* eslint-disable jsx-a11y/label-has-for */
  return (
    <label
      htmlFor={id}
      {...labelProps}
      className={`${selectorType}-selector ${labelClassName}`}
    >
      {children ? children(selector) : selector}
    </label>
  )
  /* eslint-enable jsx-a11y/label-has-for */
}

Selector.propTypes = {
  id: PropTypes.string.isRequired,
  labelProps: PropTypes.objectOf(PropTypes.any),
  children: PropTypes.func,
  selectorType: PropTypes.oneOf(['radio', 'checkbox']),
}

Selector.defaultProps = {
  labelProps: {},
  children: undefined,
  selectorType: 'radio',
}

Styles

.radio-selector, .checkbox-selector {
  cursor: pointer;
  min-width: 16px;
  min-height: 16px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;

  .radio-hidden, .checkbox-hidden {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
  }

  .mask {
    width: 16px;
    height: 16px;

    &.margin-left {
      margin-left: 10px
    }
    &.margin-right {
      margin-right: 10px
    }
  }
}

.radio-selector {
  .radio-hidden ~ .mask::before {
    font-family: system-ui;
    content: 'â—¯';
    font-size: 15px;
  }

  .radio-hidden:checked ~ .mask::before {
    font-family: system-ui;
    content: 'â—‰';
    font-size: 15px;
  }

  .radio-hidden:disabled ~.mask::before {
    color: #b6b6b6;
    cursor: default;
  }

  &:hover .radio-hidden:not(:disabled):not(:checked) ~ .mask::before {
    color: #dd7758;
  }
}

.checkbox-selector {
  .checkbox-hidden ~ .mask::before {
    font-family: system-ui;
    content: 'â–¡';
    font-size: 17px;
  }

  .checkbox-hidden:checked ~ .mask::before {
    font-family: system-ui;
    content: 'â– ';
    font-size: 17px;
  }

  .checkbox-hidden:checked ~ .mask::after {
    font-family: system-ui;
    content: '\2713';
    color: #fff;
    height: 15px;
    width: 15px;
    font-weight: 100;
    position: absolute;
    font-size: 13px;
    text-align: center;
    margin: 1px 0 0 -15px;
  }

  .checkbox-hidden:disabled ~.mask::before {
    color: #b6b6b6;
    cursor: default;
  }

  &:hover .checkbox-hidden:not(:disabled):not(:checked) ~ .mask::before {
    color: #dd7758;
  }
}

Usage

  <Selector defaultChecked selectorType="checkbox">
    {
      selector => (
        <>
          {selector}
          {` Check me`}
        </>
      )
    }
  </Selector>

Your assistance in resolving this matter would be greatly appreciated!

Answer â„–1

It appears to be a CSS issue that is causing the problem.

One common solution for this type of issue is to ensure that any tags with absolute positioning are contained within a tag with position: relative. Additionally, you should specify the position for each instance using top: 0; left: 0. To avoid discrepancies in appearance across different browsers, you can also use display: none to hide the check boxes as simply setting height: 0; and width: 0; may not produce the desired results. By following these steps, you can make your check boxes compatible with various browsers.

Answer â„–2

A problem arose in Firefox due to the use of font-family: system-ui. By making adjustments and using a different set of font-families along with their respective fallbacks, the issue was resolved successfully:

font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

You can find the corrected code here:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I modify certain attributes within an array of objects?

https://i.sstatic.net/TKkcV.jpgI need help with updating properties within an object array. Below is my code for reference. I have an object array consisting of two arrays, where the first one contains attribute "first" and the second one contains "last". ...

HTML source does not contain nested link elements for linked areas with nested hyperlinks

I want to create a visually and functionally appealing hyperlink within a larger rectangular shape that spans the full width of the page and is also a hyperlink itself. Below, you'll find an ASCII-art representation of what I'm trying to achieve: ...

The ThemeProvider is throwing an error that says it cannot access the $$material property since it is undefined

ThemeProvider.js:16 Uncaught TypeError: Cannot read properties of undefined (reading '$$material') at ThemeProvider (ThemeProvider.js:16:23) at Main.fs.js:21:13 package.json: "dependencies": { "@azure/msal-browser": " ...

Adjust the text size to fit perfectly within the boundaries of a textarea input field

Is there a way to ensure that users type within a specific area with formatting and returns in a textarea element? I'm looking for a solution that limits overflow and ensures users stay within the designated area. How can this be achieved? I am worki ...

CSS modified after opening a modal dialog that has loaded external HTML content

Within my ASP.NET MVC project, I am utilizing a tab wizard. On one of the tabs, I trigger a modal dialog by loading HTML content from an external API. However, once I close the wizard and navigate to the next tab, the table style (specifically border color ...

Issues with cookies are preventing functionality when accessing a developmental version of a Next application on a mobile device

During testing of my Next JS development build on a mobile phone, I accessed it using a private IP address (192.XXX.X.24:3000) rather than localhost:3000 on my development machine. The pages load correctly, but when attempting to send cookies back to the b ...

Differentiating Angular HTML and script code is a fundamental practice in Angular development

I am working on an angular frontend project that includes a dashboard component with a sidebar. The code currently has both the script tag and HTML code in the same file, making it difficult to manage. I am looking for a way to separate them to make the co ...

Guide on populating a textbox with values through Ajax or Jquery

Consider the scenario where there are three textboxes. The first textbox requires an ID or number (which serves as the primary key in a table). Upon entering the ID, the semester and branch fields should be automatically filled using that ID. All three fie ...

What causes async / await function to be executed twice?

I am currently developing a node.js application using express. In this project, I have implemented a regular router that performs the following tasks: It searches for the myID in the DB, If the myID is found, it attempts to execute the addVisit() functio ...

The SpotLight class in Three.js illuminating a dynamic JSON model

Attempting to understand the light classes in three.js has been a bit of a challenge for me. I've been experimenting with an example in three.js, trying to place a 3D mesh model on the screen and give it a simple rotating animation. Is there a way to ...

I am having trouble with the CSS Hover and Active styling on my website

Below is the code for my navigation bar: <ul> <li><a href="index.html">HOME</a></li> <li><a href="portfolio.html">PORTFOLIO</a></li> <li><a href="resources.html">RESOURCES</a ...

A guide to accessing a property value in Angular 6 from an object using a string key

In my Angular application, I am receiving an object with multiple arrays from a REST service. I need to access the value from the incoming object based on the property name. Here is what the object looks like: data{ array1:{}, array2:{}, array3:{} } Th ...

Rails assets folder is not directed to the specified directory in the layout file

I have a dilemma in the application layout where I'm referencing assets (js, css, and img) in the public/assets/... directory. For example: <link href='assets/images/meta_icons/apple-touch-icon-144x144.png' rel='apple-touch-icon-pre ...

Creating a scrolling list group in a single column that moves in sync with another longer column

When working with two columns in Bootstrap, such as col-4 and col-8, how can you ensure that a list-group stays fixed within its column and vertically aligned even when the content in the other column is scrolled down? Dealing with this responsively can b ...

"Enhance your website with Express.js and eliminate the need for full

As I continue to work on my website, I am faced with a challenge. While the page is not overly large, I want to ensure that when navigating to different tabs in the navbar, the entire site does not have to reload each time. Currently, I am using express.js ...

Is there a way to ensure that HTML5 audio is responsive when using Bootstrap?

I need help with making my HTML5 audio player responsive in Bootstrap. Here is the code I currently have: <div class="col-sm-4 col-sm-offset-4"> <audio controls style="width: 600px;"> <source src="sample.mp3"> < ...

The ng-disabled directive in Angular JS is not effectively disabling a button

Why is the button not disabled? var mainApp = angular.module('mainApp', []); mainApp.controller('mainController', function ($scope) { $scope.form = { login: '' }; }); <form ng-controller="LoginAppCtrl as ...

How can I fix the issue where the outline flashes in various colors when focusing on an element?

Encountered an unusual issue with :focus-visible in Chrome, Edge, and Canary. Trying to add a purple outline to the anchors on a navbar when they are focused via keyboard. The class includes outline: $the-purple-color auto 1px !important. However, upon fo ...

Navigating Successful or Unsuccessful Payment Routing within the Razorpay System

Recently started exploring Payment Gateway Integration and need assistance. I am looking for guidance on redirecting a URL after successful or failed payments in Razorpay. I need JavaScript code for this purpose. I believe the handler function can be util ...

Tips on integrating jQuery into html2canvas:

$('#button').on('click', function() { var element = $("#html-content-holder"); // global variable var getCanvas; // global variable html2canvas(element, { onrendered: function(canvas) { getCanvas = canvas; } }); ...