question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make the default `size` be equal to 1, not null

See original GitHub issue

Please make the size prop default to 1 if no value is provided. If you leave size off, the icon simply will not render (0 viewbox).

In most cases,

<Icon path={mdiMenu} />

is preferable to

<Icon path={mdiMenu} size={1} />

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
mririgoyencommented, Nov 8, 2018

It seems extremely silly to have to specify widths for every use of every icon. I want to use an icon, and I expect it to appear when I put it in my code. If I want to further style that icon, I can then choose to add the optional size prop or use CSS.

Currently, a page with 15+ icons on it either has to look like:

<Icon path={mdiMenu} size={1} />
<Icon path={mdiAccount} size={1} />
<Icon path={mdiAttachment} size={1} />
...

or

<Icon className='my-class' path={mdiMenu} />
<Icon className='my-class' path={mdiAccount} />
<Icon className='my-class' path={mdiAttachment} />
...

The latter having additional CSS just to get over the hurdle of making the icon appear. Both have more boilerplate than I think should be needed for an out-of-the-box and quick way to get an icon to appear in my app.


EDIT: Perhaps a default class goes on all icons of “mdi”, so that at least all MDI icons can be targeted with CSS instead of needing to specify classes on each use.

So, with this proposal…

<Icon path={mdiMenu} />

Would render:

<svg viewbox="0 0 24 24" class="mdi">...</svg>

and

<Icon className='my-class' path={mdiMenu} />

Would render:

<svg viewbox="0 0 24 24" class="mdi my-class">...</svg>

I also like this approach, even though it does still require me to put something in my stylesheet just to get an icon to appear, which I find weird.

1reaction
Templariancommented, Nov 9, 2018

Prior to the v1.0 release of this it was defaulting to 1 for size, but was causing a lot of issues for people using it alongside their frameworks since it added the style attribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Constraints in SQL Server: SQL NOT NULL, UNIQUE and SQL ...
This article explains the useful constraints SQL NOT NULL, Unique and Primary Key constraints in SQL Server examples with user cases.
Read more >
Why is adding a NOT NULL column with a default constraint ...
Yes, adding a column with NOT NULL and a default doesn't actually write the values to all the rows at the time of...
Read more >
NOT NULL constraint asking for a default value - Stack Overflow
By specifying a default value, you are ensuring that any existing rows are assigned that value, thereby complying with your NOT NULL constraint....
Read more >
Altering a Column from Null to Not Null in SQL Server - Chartio
Alter a column from NULL to not NULL in SQL Server by updating existing column data and altering the column data structure to...
Read more >
MySQL 8.0 Reference Manual :: 11.6 Data Type Default Values
CREATE TABLE t1 ( i INT DEFAULT -1, c VARCHAR(10) DEFAULT '', price DOUBLE(16,2) DEFAULT 0.00 );. SERIAL DEFAULT VALUE is a special...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found