Reputation: 573
How print the newline/return in placeholder text in Formik textarea. I've tried \n, nothing seems to be working.
// , didn't work
<Field
className="form-control"
component="textarea"
name="dayWiseItinerary"
rows="6"
placeholder="
day 1: Temple visit,
day 2: Jungle barbeque,\n
day 3: Waterfall visit in the evening,\n
day 4: Visit UNESCO World Heritage Site,\n
day 5: Art gallery show,\n
day 6: Visit grand swimming pool,\n
day 7: Visit to Blue fort
"
/>
Upvotes: 3
Views: 12340
Reputation: 3286
Expanding on @Drew Reese answer, and regarding his note about whitespaces, you can also do this:
<textarea
cols={40}
placeholder={'day 1: Temple visit, '
+ 'day 2: Jungle barbeque,\n'
+ 'day 3: Waterfall visit in the evening,\n'
+ 'day 4: Visit UNESCO World Heritage Site,\n'
+ 'day 5: Art gallery show,\n'
+ 'day 6: Visit grand swimming pool,\n'
+ 'day 7: Visit to Blue fort'}
rows={20}
/>
Upvotes: 0
Reputation: 203051
Template Literals allow you to specify a multi-line string of text.
<textarea
cols={40}
placeholder={`day 1: Temple visit,
day 2: Jungle barbeque,\n
day 3: Waterfall visit in the evening,\n
day 4: Visit UNESCO World Heritage Site,\n
day 5: Art gallery show,\n
day 6: Visit grand swimming pool,\n
day 7: Visit to Blue fort`}
rows={20}
/>
Note: Since this is a string template literal, be mindful of the whitespace within the templating. Notice above that the leading whitespace for each line is absent. Also notice now the newlines \n
are rendered.
Upvotes: 1