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.

Hide Button while using IconButton

See original GitHub issue

I want to display Icon & allow it to be clickable which is why I need the IconButton component.

The problem comes when I need to show only icon but hide the button and I’m unable to do that.

Here’s the contents of my IconButton

import { Flex, IconButton } from '@chakra-ui/core'
import React from 'react'

export const CreateHabit = () => (
  <Flex
    width='220px'
    height='220px'
    borderRadius='40px'
    margin='0 16px'
    padding='0 16px'
    justify='center'
    flexWrap='wrap'
  >
    <IconButton
      onClick={() => alert('click')}
      icon='add'
      variant='unstyled'
      fontSize='300px'
    />
  </Flex>
)

And right now you can see how it looks ⸺

chakra-ui-bug

Notice the button’s outline above the add icon. I want to hide the button completely so that my icon will move up a bit in alignment 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bawahakimcommented, Feb 16, 2021

For those still looking for a way to work with ally/tab

                 <IconButton
                        aria-label="Share Program"
                        icon={<LinkIcon boxSize={6} color="gray.400" />}
                        onClick={invitePeopleDisclosure.onOpen}
                        w="fit-content"
                        variant="ghost"
                      />

The secret is the variant and the fit-content

0reactions
segunadebayocommented, Dec 2, 2019

I’d suggest you use the PseudoBox component to create that button.

<PseudoBox as="button" onClick={...}><Icon name="add"/></PseudoBox>

Let me know if this helps. If not, I’ll re-open the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to display an IconButton that is hidden on button click ...
Show activity on this post. I have in my ViewModel class, a State object with the default value of false . Nothing happens....
Read more >
Hide and show a button based on the content of the Gallery
I have a problem with showing and hiding an icon/button. I want to make the Gallery button invisible while the Gallery is still...
Read more >
IconButton API - Material UI - MUI
API reference docs for the React IconButton component. Learn about the props, CSS, and other APIs of this exported module.
Read more >
IconButton class - material library - Flutter - Dart API docs
When creating an icon button with an Icon, do not override the icon's size with its Icon.size parameter, use the icon button's iconSize...
Read more >
Button Icons - Lightning Design System
If an icon button doesn't include a label, use a title attribute to show on hover for ... When using assistive text, the...
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