Guides and Sample Code


Apple News Format: Design Tutorial

On This Page

Mosaic Components

You can use a mosaic component to display images as a set of tiles. This is a good component to use for images that you want to show in juxtaposition.

image: ../Art/mosaic-closeup_2x.png
image: ../Art/anatomy2_2x.png

You’ll place a mosaic component in the components array. Define gallery items for mosaics just as you would for galleries. In a mosaic, the order of gallery items in the array, along with other factors, influences the order of the images. For each gallery item, the value of the URL property works as it does for photo components.

For information on customizing mosaic components, see Mosaic and Gallery Item in the Apple News Format Reference.

Image Guidelines

For image guidelines, see Image Guidelines and Mosaic in the Apple News Format Reference.

JSON Example: Mosaic Component

Create a mosaic component that contains five images. Also, create a level-2 heading and a caption component. Within each gallery item, include an image-specific caption property. For more information about captions, see Captions in this tutorial.

The noMarginLayout, halfMarginBothLayout, and fullMarginBelowLayout component layout objects were defined earlier in the tutorial. For the purposes of this tutorial, a “full margin” was considered to be a space of 24 points above or below a component, and a “half margin” to be a space of 12 points.

Example Code

Ellipses (...) indicate lines of code that have been omitted from this example.

  1. {
  2. ...
  3. "components": [
  4. ...
  5. {
  6. "role": "heading2",
  7. "layout": "fullMarginAboveHalfBelowLayout",
  8. "text": "MOSAIC HEADING"
  9. },
  10. {
  11. "role": "mosaic",
  12. "layout": "noMarginLayout",
  13. "items": [
  14. {
  15. "URL": "bundle://mosaic-01.jpg",
  16. "caption": "A caption for the first image in the mosaic."
  17. },
  18. {
  19. "URL": "bundle://mosaic-02.jpg",
  20. "caption": "A caption for the second image in the mosaic."
  21. },
  22. {
  23. "URL": "bundle://mosaic-03.jpg",
  24. "caption": "A caption for the third image in the mosaic."
  25. },
  26. {
  27. "URL": "bundle://mosaic-04.jpg",
  28. "caption": "A caption for the fourth image in the mosaic."
  29. },
  30. {
  31. "URL": "bundle://mosaic-05.jpg",
  32. "caption": "A caption for the fifth image in the mosaic."
  33. }
  34. ]
  35. },
  36. {
  37. "role": "caption",
  38. "layout": "halfMarginBothLayout",
  39. "text": "ABOVE: A caption for the entire mosaic. Individual photos in the mosaic also have their own captions. (Shared attribution)"
  40. },
  41. {
  42. "role": "divider",
  43. "layout": "noMarginLayout",
  44. "stroke": {
  45. "width": 1,
  46. "color": "#D5B327"
  47. }
  48. },
  49. ...
  50. ],
  51. ...
  52. }

Further Exploration

At any time, you can try changing property values in your article.json file, and then use News Preview to see how these changes impact the look of your article.

For example, try changing the order of gallery items in your mosaic component by changing URLs:

  1. In your code, find the mosaic component.

  2. In the first gallery item’s URL property, replace the 01 with 02.

  3. In the first gallery item’s URL property, replace the 02 with 01.

  4. Preview your article.json file in News Preview. See also: Updating Your Article Preview.

    The order of your first and second images has been switched.