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.

Paragraph to support "fill" prop

See original GitHub issue

Just an observation on Paragraph.

9/10 times the max-width makes total and complete sense. Then, there’s that one time when you want the paragraph’s width controlled by its parent Box. Currently the only fix is to replace the Paragraph calls with the non-semantic Text component.

Proposed Solution

There is a property, we’ll call it fill for now, which behaves like the box’s fill property, allowing for the values ["horizontal", "vertical", true, false]. The default value of this would be false, and provides the current behavior.

  • A value of horizontal will set width to 100%
  • A value of vertical will set height to 100%
  • A value of true sets both above
  • A value of false takes the max-width setting from the paragraph’s definition, along with the other Paragraph defaults

Alternatives

Box+Text

This is probably the cleanest workaround, although it does not satisfy the requirements of a semantic <p> tag in output. <Box as="p"><Text>...content</Text></Box> will give you all of the flex/box support you’d want with an inner text object. The only drawback is the non-semantic <span> added inside the paragraph.

If we opted for this solution, we would want to update the grommet documentation to explain how to do paragraphs that don’t force a maximum width for readability.

Text as=

This is a variant of the above, using the as prop to change Text from its default span to a p tag. It has some drawbacks though, as using Text by itself forgoes grommet’s support for border, animation, background, and others.

Reference

  • Reference on behavior of fill in the StyledBox https://github.com/grommet/grommet/blob/master/src/js/components/Box/StyledBox.js#L120
  • #1775 we actually talked about this once before. Paragraph has strong opinions on its default width (good!) but no way for someone to create a semantic <p> tag and override the Paragraph in specific instances (bad!). The solution of manually doing <p><Text>...content</Text></p> or <Box><Text>...content</Text></Box> are workarounds.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jakobocommented, Aug 22, 2019

Sure. I’ll give it a shot. I think @ericsoderberghp’s true|false solution will work. Just going to enumerate todos here before I open a WIP PR.

[ ] Paragraph true|false [ ] Update docs (new prop) [ ] Storybook story

(Missing anything?)

1reaction
ericsoderberghpcommented, Jul 29, 2019

I’m OK with the basic concept of being able to override the max-width for special circumstances.

One other options is to do style={{ maxWidth: 'none' }}. This might be sufficient if the frequency is low enough.

I’m OK with using fill as a property to control this. My inclination is to just support true|false values though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<p>: The Paragraph element - HTML - MDN Web Docs - Mozilla
The HTML element represents a paragraph. Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks ...
Read more >
Fill in the blank field: Add more options to format the ... - Jotform
Hey,The fill in blank property has many bugs around formatting. Indents never stay, spacing never stays. Below is an example.
Read more >
Main Idea Practice Paragraphs 1-6
The main idea is the central, or most important, idea in a paragraph or passage. It states the purpose and sets the direction...
Read more >
Organizational Patterns of a Paragraph | Cuesta College
Although key signal words help in identifying the particular type of pattern, a single paragraph can be a mixture of different patterns.
Read more >
HTML DOM Paragraph Object - W3Schools
Paragraph Object Properties. Property, Description. align, Not supported in HTML5. Use style.textAlign instead. Sets or returns 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