Skip to content

Request: containerId prop #13

@johncip

Description

@johncip

Hey, I like your modal component and have been using it. Unlike many others, it doesn't have a ton of dependencies, or do nasty things with focus, or add 50k to my page weight :)

One thing that would be useful is if the API allowed setting the ID of the "container" div, in addition to its class. Using IDs helps with CSS specificity, and often you only have one instance of a modal anyway, which using IDs helps to document in the stylesheet.

(I know I have full control over the child elements I pass in, but I'm currently using your modal in a context where adding another div isn't a great option.)

On that note, I think it'd also be nice if instead of className and containerClassName, the props were overlayClassName and className, respectively. Then using it would look something like,

<Modal id='apple-modal' className='responsive-modal'>
  Apples
</Modal>

<Modal id='banana-modal' className='responsive-modal'>
  Bananas
</Modal>
.responsive-modal
  max-width: 500px
  @media (max-width: 540px)
    width: calc(100% - 40px)

#apple-modal
  color: red

#banana-modal
  color: yellow

In my mind, "modal" is short for "modal dialog" and what you refer to as the container, I think of as the top-level element of that dialog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions